/*******************************************************************************
*  Project      : Minigate Golfin                                 
*  Program ID   : common.js                                 
*  Description  : 기본함수                                             
*
********************************************************************************
*  Program History                                                            
*  Date        Author    Description                                          
*  ----------  --------  -------------------------------------------------------- 
*  2012-04-03  김효순    Created.                                             
*  2012-04-09  김효순    getParam 추가     
*  2012-04-10  김효순    로그인, 로그아웃 처리
*  2012-04-12  김효순    left 메뉴 펼침기능
*  2012-04-18  김효순    모달로딩 클래스 추가
*  2012-04-18  김효순    아이디, 비밀번호 찾기 링크 추가
*******************************************************************************/
var _ROOT = "";
var _UPLOADPATH_TMP = "/data/msp300/dl/files/free/tmp";
var _UPLOADPATH = "/data/msp300/dl/files/free/uploaded";
var _UPLOADURL_TMP = _ROOT + "/tmp";
var _UPLOADURL = _ROOT + "/uploaded";
var _IMGURL = "http://" + document.domain;
var _LOGIN_TEXT = "로그인 후 이용하실 수 있습니다.";

var _COURSE_IMG_PATH = "/data/msp300/dl/files/free/asp/editinfo/course/";
var _COURSE_IMG_URL = _ROOT + "/_course_img/";

//js를 동적으로 로딩한다.
//jquery와 독립적인 로딩시 또는 jquery로딩 오류발생시 사용.
function fnLoadingJS(url, callback)
{
	var head= document.getElementsByTagName('head')[0];
	var script= document.createElement('script');
	script.type= 'text/javascript';
	var loaded = false;
	script.onreadystatechange= function () {
		
		if (this.readyState == 'loaded' || this.readyState == 'complete') {
			if (loaded) {
				return;
			}
			loaded = true;
			callback();
		}
	}

	script.onload = function () {
		callback();
	}

	script.src = url;
	head.appendChild(script);
}

if(!String.trim){
	String.prototype.trim = function(){
		return this.replace(/^\s*/, "").replace(/\s*$/, "");
	}
}

//개행문자와 큰따옴표로 인해 ajax전송시 오류가 발생되지 않도록
//문자열을 변환한다.
if(!String.ajaxTrans){
	String.prototype.ajaxTrans = function(){
		return this.replace(/\n/g, "\\n").replace(/"/g, "\\\"");
	}
}

if(!String.enter2br){
	String.prototype.enter2br = function(){
		return this.replace(/\n/g, "<br>");
	}
}

//substr 메소드의 옵션에 마이너스 값설정이 가능하도록 설정
if(!String.substrEx){
	String.prototype.substrEx = function(){
		var szRet = "";
		
		if(arguments.length == 1){
			szRet = this.substr(arguments[0]);
			
			if(parseInt(arguments[0]) < 0 && szRet.length != Math.abs(arguments[0])){
				szRet = this.substr(this.length +  arguments[0]);
			}
		}else{
			szRet = this.substr(arguments[0], arguments[1]);
		}
		
		return szRet;
	}
}

var _gf = null;
var _util = null;
var _ip = null;
var _window_loaded = null;

$(window).on("load", null, function(){
	_window_loaded = true;
});

//document.write("<div id='idPreLoad' style='position:absolute; width:" + screen.availWidth + "px; height:" + screen.availHeight + "px; left:0; top:0; background-color:white; z-index:100;'  />");

//(function a(){
//	if($("body").length){
//		$("body").prepend("<div id='idPreLoad' style='position:absolute; width:" + screen.availWidth + "px; height:" + screen.availHeight + "px; left:0; top:0; background-color:white; z-index:100;'  />");
//	}else{
//		setTimeout(function(){
//			a();
//		}, 100);
//	}
//})();

// 파이어폭스에서 설정시 페이지 로딩 후 show가 되지않는 현상이 발생되어
// 파이어폭스에서는 화면을 숨기지 않음.
//if(navigator.userAgent.toLowerCase().indexOf("firefox") == -1){
	document.write("<style>body{visibility:hidden;}</style>");
//}

jQuery(function($){
//	$.ajax({
//		url: "/ip"
//		, type: "get"
//		, dataType: "json"
//		, async: false
//		, success: function(ret){
//			_ip = ret["ip"];
//		}
//	});
	
	// 모든 form 전송을 막음.
	// form전송이 필요할시 id=idPermissionForm
	$(document).on("submit", "form:not(#idPermissionForm):not(form[id^=jUploadForm])", function(){
		return false;
	});
	
	// 모든 링크를 막음
	// 링크가 필요할 시 id=idPermissionLink
	$(document).on("click", "a:not(#idPermissionLink)", function(event){
		event.preventDefault();
	});
	
	$("header").on("click", "div#logo a", function(){
		document.location.href = "/index";
	});
	
	$(document).on("keyup", null, function(){
		var e = arguments[0] || event;
		
		if(e.target.tagName.toUpperCase() != "BODY") return;
		
		var egg_key = $(this).data("egg_key") || "";
		$(this).data("egg_key", egg_key + String.fromCharCode(e.keyCode));
		
		egg_key = $(this).data("egg_key");
		
		switch(egg_key.length){
			case 0:
				if(e.keyCode != 71) $(this).data("egg_key", null);
				break;
			case 1:
				if(e.keyCode != 75) $(this).data("egg_key", null);
				break;
			case 2:
				if(e.keyCode != 83) $(this).data("egg_key", null);
				break;
			case 3:
				if(e.keyCode != 83) $(this).data("egg_key", null);
				break;
			case 4:
				if(e.keyCode != 75) $(this).data("egg_key", null);
				break;
			default:
				$(this).data("egg_key", null);
				break;
		}
		
		egg_key = $(this).data("egg_key");
		
		if(egg_key && egg_key.length == 4){
			alert(String.fromCharCode(0xD55C, 0xB098) + "?");
		}
	});
	

	// 로딩 에니메이션
	$.fn.spin = function(opts) {
		this.each(function() {
			var $this = $(this),
			data = $this.data();
			
			if (data.spinner) {
				data.spinner.stop();
				delete data.spinner;
			}
			if (opts !== false) {
				data.spinner = new Spinner($.extend({color: $this.css('color')}, opts)).spin(this);
			}
		});
		return this;
	};
	
	// 특정 텍스트 감싸기
	// 예) $("div").textWrap("123", "<span>");
	$.fn.textWrap = function(pat, DOMText) {
		function innerWrap(node, pat) {
			var skip = 0;
			if (node.nodeType == 3) {
				var pos = node.data.toUpperCase().indexOf(pat);
				if (pos >= 0) {
					var middlebit = node.splitText(pos);
					var endbit = middlebit.splitText(pat.length);
					$(middlebit).wrap(DOMText);
					skip = 1;
				}
			}
			else if (node.nodeType == 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) {
				for (var i = 0; i < node.childNodes.length; ++i) {
					i += innerWrap(node.childNodes[i], pat);
				}
			}
			return skip;
		}
		
		return this.each(function() {
			innerWrap(this, pat.toUpperCase());
		});
	};
	
	// top 메뉴
	function clsTopMenu()
	{
		this._HTMLDom = null;
		
		this.bookingAlimList = null;
		this.alimList = null;
		this.noteAlimList = null;
		
		this.bLoaded = false;
		this._loadpage = _ROOT + "/inc/top.html";
		this._load();
	}
	
	clsTopMenu.prototype = {
		_load : function(){
			var thisClass = this;
			
			$.ajax({
				url: this._loadpage
				, type: "get"
				, dataType: "html"
				, async: false
				, success: function(ret, sta){
					$("header").prepend(ret);
					thisClass._init();
				}
			});
			
			/*if($("header").children().length > 0){
				$("header").prepend("<div></div>").children(":first").load(this._loadpage, function(){thisClass._init();});	
			}else{
				$("header").load(this._loadpage, function(){thisClass._init();});
			}*/
		}
		, _init: function(){
			var $layer = $("div.top_menu");
			
			this._HTMLDom = {
				"$layer": $layer
				, "$btnLogout": $layer.find("#idBtnLogout")
			}
			
			$layer.on("click", "a:not(#idPermissionLink)", function(event){
				event.preventDefault();
			});
			
			this.bookingAlimList = [];
			
			this.alimList = [];
			
			this.noteAlimList = [];
			
			var p = _util.getSelfFileName();
			
			$layer.find("li.li_link").find("a").hide();
			
			if(!(p[p.length-2] ==  "index" && p[p.length-3] == "index")){
				$layer.find("span:contains('골프인 홈')").parent("a").attr({
					"id": "idPermissionLink"
					, "href": _ROOT + "/index"
				}).show();
				
				if(_util.getCookie("member_id")){
					$layer.find("a:contains('로그아웃')").show();
					if(p[p.length-3] != "mypage"){
						$layer.find("span:contains('마이골프인')").parent("a").attr({
							"id": "idPermissionLink"
							, "href": _ROOT + "/mypage/my_home.html"
						}).show();
					}
				}else{
					$layer.find("a:contains('로그인')").show();
					$layer.find("span:contains('회원가입')").parent("a").attr({
						"id": "idPermissionLink"
						, "href": _ROOT + "/member/join_01.html"
					}).show();
				}
			}
			
			$layer.find("ul:first>li:eq(0)").hide();
			$layer.find("ul:first>li:eq(1)").hide();
			$layer.find("ul:first>li:eq(2)").hide();
			
//			$layer.find("ul:first>li:eq(0) span.boo").html(0);
//			$layer.find("ul:first>li:eq(1) span.frie").html(0);
//			$layer.find("ul:first>li:eq(2) span.info").html(0);
			
			this.setBookingAlimList([]);
			this.setAlimList([]);
			this.setNoteAlimList([]);
			
//			$layer.find("ul:first>li:eq(0) div.top_booking").hide().find("ul").empty();
//			$layer.find("ul:first>li:eq(1) div.top_friend").hide().find("ul").empty();
//			$layer.find("ul:first>li:eq(2) div.top_info").hide().find("ul").empty();
			
			//$(this).trigger("onload");
		}
		, $getLayer: function(){
			return this._HTMLDom["$layer"];
		}
		, $getBtnLogout: function(){
			return this._HTMLDom["$btnLogout"];
		}
		, getLoaded: function(){
			var bLoaded = false;
			
			if(this._HTMLDom && this._HTMLDom["$layer"].length > 0) bLoaded = true;
			return bLoaded;
		}
		, setBookingAlimList: function(thisData){
			this.bookingAlimList = thisData;
			this.displayBookingAlim();
		}
		, setAlimList: function(thisData){
			this.alimList = thisData;
			this.displayAlim();
		}
		, setNoteAlimList: function(thisData){
			this.noteAlimList = thisData;
			this.displayNoteAlim();
		}
		, setBookingAlarmList: function(thisData){
			this.bookingAlarmList = thisData;
			this.display();
		}
		, setFriendAlarmList: function(thisData){
			this.friendAlarmList = thisData;
			this.display();
		}
		, setAlarmList: function(thisData){
			this.alarmList = thisData;
			this.display();
		}
		, display: function(){
			var $layer = this._HTMLDom["$layer"];
			var member_id = document.objUtil.getCookie("member_id");
			var $bookingAlarmLayer = $layer.find("ul:first>li:eq(0) div.top_booking");
			var $friendAlarmLayer =  $layer.find("ul:first>li:eq(1) div.top_friend");
			var $alarmLayer =  $layer.find("ul:first>li:eq(2) div.top_info");
			var thisClass = this;
			
			$layer.find("ul:first>li:eq(0) span.boo").html(this.bookingAlimList.length);
			$layer.find("ul:first>li:eq(1) span.frie").html(this.alimList.length);
			$layer.find("ul:first>li:eq(2) span.info").html(this.noteAlimList.length);
			
			// 부킹 알람 리스트
			$bookingAlarmLayer.hide().find("ul").empty();
//			for(var i=0;i<this.bookingAlarmList.length;i++){
//				var szNick = this.bookingAlarmList[i]["닉네임"];
//				var szMessage = this.bookingAlarmList[i]["메시지"];
//				//if(!szNick) szNick = "";
//				
//				switch(this.bookingAlarmList[i]["종류"]){
//					case "부킹예약":
//						$bookingAlarmLayer.find("ul").append("<li><div>" + this.bookingAlarmList[i]["메시지"] + "</div></li>");
//						break;
//					case "조인룸초대":
//						$bookingAlarmLayer.find("ul").append("<li></li>");
//						$bookingAlarmLayer.find("ul>li:last").append("<div>" + this.bookingAlarmList[i]["메시지"] + "</div>\n");
//						$bookingAlarmLayer.find("ul>li:last").append("<div class='top_bt'>\n<a href='#'><img src='../images/btn/btn_accept.gif' alt='수락'></a>\n<a href='#'><img src='../images/btn/btn_deny.gif' alt='거부'></a>\n</div>");
//						$bookingAlarmLayer.find("ul>li:last a:eq(0)").click({"n": i}, function(event){
//							event.preventDefault();
//							var n = event.data["n"];
//							
//							alert(thisClass.bookingAlarmList[n]["아이디"] + "수락");
//						});
//						$bookingAlarmLayer.find("ul>li:last a:eq(1)").click({"n": i}, function(event){
//							event.preventDefault();
//							var n = event.data["n"];
//							
//							alert(thisClass.bookingAlarmList[n]["아이디"] + "거부");
//						});
//						break;
//					case "조인룸참여":
//						$bookingAlarmLayer.find("ul").append("<li><div>" + this.bookingAlarmList[i]["메시지"] + "</div></li>");
//						break;
//					case "예정조인룸참여":
//						$bookingAlarmLayer.find("ul").append("<li><div>" + this.bookingAlarmList[i]["메시지"] + "</div></li>");
//						break;
//					default: 
//						$bookingAlarmLayer.find("ul").append("<li><div>" + this.bookingAlarmList[i]["메시지"] + "</div></li>");
//						break;
//				}
//				
//				if(szNick) $bookingAlarmLayer.find("ul>li:last").textWrap(szNick, "<span class='top_txt02' />");
//				var aDate = szMessage.match(/(\d{4}\.\d{2}\.\d{2})/gi);
//				
//				if(aDate){
//					for(var x=0;x<aDate.length;x++){
//						$bookingAlarmLayer.find("ul>li:last").textWrap(aDate[x], "<span class='top_txt01' />");
//					}
//				}
//			}
			
			// 친구 알람 리스트
			$friendAlarmLayer.hide().find("ul").empty();
//			for(var i=0;i<this.friendAlarmList.length;i++){
//				var szNick = this.friendAlarmList[i]["닉네임"];
//				var szMessage = this.friendAlarmList[i]["메시지"];
//				
//				switch(this.friendAlarmList[i]["종류"]){
//					case "친구요청":
//						$friendAlarmLayer.find("ul").append("<li><div class='top_fr_cont'></div></li>");
//						$friendAlarmLayer.find("ul>li:last>div").append("<p class='top_photo'><img src='" + this.friendAlarmList[i]["이미지"] + "' alt='' width='35' height='35' /></p>");
//						$friendAlarmLayer.find("ul>li:last>div").append("<div class='top_accept'><p>" + this.friendAlarmList[i]["메시지"] + "</p></div>");
//						$friendAlarmLayer.find("ul>li:last>div>div.top_accept").append("<p>\n<a href='#'><img src='../images/btn/btn_accept.gif' alt='수락'></a>\n<a href='#'><img src='../images/btn/btn_deny.gif' alt='거부'></a>\n</p>");
//						
//						$friendAlarmLayer.find("ul>li:last a:eq(0)").click({"n": i}, function(event){
//							event.preventDefault();
//							var n = event.data["n"];
//							
//							alert(thisClass.friendAlarmList[n]["아이디"] + "수락");
//						});
//						$friendAlarmLayer.find("ul>li:last a:eq(1)").click({"n": i}, function(event){
//							event.preventDefault();
//							var n = event.data["n"];
//							
//							alert(thisClass.friendAlarmList[n]["아이디"] + "거부");
//						});
//						break;
//					default:
//						$friendAlarmLayer.find("ul").append("<li><div>" + this.friendAlarmList[i]["메시지"] + "</div></li>");
//						break;
//				}
//				
//				if(szNick) $friendAlarmLayer.find("ul>li:last").textWrap(szNick, "<span class='top_txt' />");
//			}
			
			// 알람 리스트
			$alarmLayer.hide().find("ul").empty();
//			for(var i=0;i<this.alarmList.length;i++){
//				var szNick = this.alarmList[i]["닉네임"];
//				
//				$alarmLayer.find("ul").append("<li><div>" + this.alarmList[i]["메시지"] + "</div></li>");
//				
//				if(szNick) $alarmLayer.find("ul>li:last").textWrap(szNick, "<span class='top_txt' />");
//			}
		}
		, displayBookingAlim: function(){
			var $layer = this.$getLayer();
			var $bookingAlarmLayer = $layer.find("div.top_booking");
			var thisClass = this;
			
			if(!_util.getCookie("member_id")) return;
			
			$bookingAlarmLayer.parent().show();
			
			var cnt = 0;
			for(var i=0;i<this.bookingAlimList.length;i++){
				if(this.bookingAlimList[i]["읽음여부"] != "Y") cnt++;
			}
			
			$bookingAlarmLayer.hide().prev("span").hide();
			
			if(cnt) $bookingAlarmLayer.hide().prev("span").show().html(cnt);
			
			// 부킹 알람 리스트
			$bookingAlarmLayer.find("ul").empty();
			for(var i=0;i<this.bookingAlimList.length;i++){
				var d = this.bookingAlimList[i];
				_gf.$getAlim({
					"템플릿코드": d["템플릿코드"]
					, "d": d
					, "콜백": function($d, arg){
						$bookingAlarmLayer.find("ul").append($d);
					}
				});
			}
		}
		, displayAlim: function(){
			var $layer = this.$getLayer();
			var $alimLayer = $layer.find("div.top_friend");
			var thisClass = this;
			
			if(!_util.getCookie("member_id")) return;
			
			$alimLayer.parent().show();
			
			var cnt = 0;
			for(var i=0;i<this.alimList.length;i++){
				if(this.alimList[i]["읽음여부"] != "Y") cnt++;
			}
			
			$alimLayer.hide().prev("span").hide();
			
			if(cnt) $alimLayer.hide().prev("span").show().html(cnt);
			
			// 알람 리스트
			$alimLayer.find("ul").empty();
			for(var i=0;i<this.alimList.length;i++){
				var d = this.alimList[i];
				_gf.$getAlim({
					"템플릿코드": d["템플릿코드"]
					, "d": d
					, "콜백": function($d, arg){
						$alimLayer.find("ul").append($d);
					}
				});
			}
		}
		, displayNoteAlim: function(){
			var $layer = this.$getLayer();
			var $noteAlimLayer = $layer.find("div.top_info");
			var thisClass = this;
			
			if(!_util.getCookie("member_id")) return;
			
			$noteAlimLayer.parent().show();
			
			var cnt = 0;
			for(var i=0;i<this.noteAlimList.length;i++){
				if(this.noteAlimList[i]["읽음여부"] != "Y") cnt++;
			}
			
			$noteAlimLayer.hide().prev("span").hide();
			
			if(cnt) $noteAlimLayer.hide().prev("span").show().html(cnt);
			
			// 알람 리스트
			$noteAlimLayer.find("ul").empty();
			for(var i=0;i<this.noteAlimList.length;i++){
				var d = this.noteAlimList[i];
				_gf.$getAlim({
					"템플릿코드": d["템플릿코드"]
					, "d": d
					, "콜백": function($d, arg){
						$noteAlimLayer.find("ul").append($d);
					}
				});
			}
		}
	}
	
	// left 메뉴
	function clsLeftMenu()
	{
		this._HTMLDom = null;
		
		this._loadpage = _ROOT + "/inc/left_content.html";
		this._menu = null;
		this.actionTimer = null;
		
		this.myInfo = null;
		this._load();
	}
	
	
	clsLeftMenu.prototype = {
		_load : function(){
			var thisClass = this;
			this._menu = {
				"1st": null
				, "2nd": null
			};
			
			//$("#left_area").load(this._loadpage, function(){thisClass._init();});
			
			$.ajax({
				url: this._loadpage
				, type: "get"
				, dataType: "html"
				, async: false
				, success: function(ret, sta){
					$("div#left_area").prepend(ret);
					
					$("div#left_area nav.gnb_area a").attr("id", "idPermissionLink");
					thisClass._init();
				}
			});
		}
		, _init: function(){
			var $layer = $("#left_content");
			
			this._HTMLDom = {
				"$layer": $layer
			}
			
			$layer.find("nav.gnb_area ul.gnb>li:eq(2)>ul>li:eq(2)").hide();
			
			//$layer.find("dl.left_member>dd.id_save>p:eq(1)>a").hide();
			/*$layer.find("dl.left_profile>dd>p.mem_link").click(function(event){
				event.preventDefault();
				
				window.open(_ROOT + "/mypage/my_home.html");
			});*/
			
			//document.objGlobal.setPlaceHolder();
			
			// 로그인 창 또는 로그인 정보
			if(_util.getCookie("member_id")){
				this.$getLoginLayer().remove();
			}else{
				this.$getInfoLayer().remove();
				
				this.$getLoginLayer().find("input:text").attr("placeholder", "아이디");
				this.$getLoginLayer().find("input:password").attr("placeholder", "비밀번호");
				_util.setPlaceHolder(this.$getLoginLayer().find("input:text"));
				_util.setPlaceHolder(this.$getLoginLayer().find("input:password"));
				
				this.setSaveId();
			}
			
			var aFileName = _util.getSelfFileName();
			var szPath = aFileName[aFileName.length-3];
			var szFileName = aFileName[aFileName.length-2];

			if(szPath == "launge"){
				// 라운지메뉴 on
				this._menu["1st"] = "0"
				
				switch(szFileName){
					case "launge_home":
						this._menu["2nd"] = "0";
						break;
					case "notice":
					case "notice_view":
						this._menu["2nd"] = "1";
						break;
					case "customer":
					case "partner":
						this._menu["2nd"] = "2";
						break;
				}
			}else if(szPath == "booking"){
				// 부킹메뉴 on
				this._menu["1st"] = "2"
				
				switch(szFileName){
					case "booking":
					case "booking_write":
					case "booking_view":
						this._menu["2nd"] = "0";
						break;
					// 조인룸은 메뉴 재편성됨.
					case "join_room":
					case "join_room_creat":
					case "join_room_view01":
						this._menu["1st"] = "1";
						//this._menu["2nd"] = "0";
						break;
				}
			}else if(szPath == "club"){
				// 동호회메뉴 on
				this._menu["1st"] = "3"
				
				switch(szFileName){
					case "club":
					case "club_creat":
						this._menu["2nd"] = "0";
						break;
					case "club_my":
						this._menu["2nd"] = "1";
						break;
				}
			}else if(szPath == "course"){
				// 코스메뉴 on
				this._menu["1st"] = "4"
			}
			
			// 하위메뉴 숨김
			this.$getMenuLayer().find("ul:not(.gnb)").hide();
			
			
			// 대메뉴 마우스 오버위한 데이터링
			this.$getMenuLayer().find("li:has(h3)").find("h3").find("img").each(function(){
				$(this).data("src", this.src.replace(".gif", ""));
			});
			
			// 하위메뉴 마우스 오버위한 데이터링
			this.$getMenuLayer().find("li:has(h3):has(ul)").find("ul").find("img").each(function(){
				$(this).data("src", this.src.replace(".gif", ""));
			});
			
			//document.objGlobal.onLoadLeftMenu();
			
			//$(this).trigger("onload");
		}
		, $getLayer: function(){
			return this._HTMLDom["$layer"];
		}
		, $getInputID: function(){
			return this.$getLayer().find(".left_member input:text:first");
		}
		, $getInputPasswd: function(){
			return this.$getLayer().find(".left_member input:password:first");
		}
		, $getMenuLayer: function(){
			return this.$getLayer().find("nav.gnb_area");
		}
		, $getInfoLayer: function(){
			return this.$getLayer().find("dl.left_profile");
		}
		, $getLoginLayer: function(){
			return this.$getLayer().find("dl.left_member");
		}
		, $getsMenuStep1: function(){
			return this.$getLayer().find("nav.gnb_area li h3");
		}
		, $getsMenuStep2: function(){
			return this.$getLayer().find("nav.gnb_area").find("ul:not(.gnb)");
		}
		, $getBtnFindIdPw: function(){
			var $layer = this._HTMLDom["$layer"];
			
			return $layer.find("dl.left_member dt a:eq(1)");
		}
		, getMenu: function(key){
			return this._menu[key];
		}
		, setDefault: function(){
			if(!this.actionTimer) return;
			
			// 디폴트 메뉴 설정
			if(this.getMenu("1st")){
				(this.$getsMenuStep1()).parent("li").eq(this.getMenu("1st")).find("h3").trigger("mouseenter");
				
				if(this.getMenu("2nd")){
					(this.$getsMenuStep1()).parent("li").eq(this.getMenu("1st")).find("ul").find("li").eq(this.getMenu("2nd")).trigger("mouseenter");
				}
			}
		}
		, getLoaded: function(){
			var bLoaded = false;
			
			if(this._HTMLDom && this._HTMLDom["$layer"].length > 0) bLoaded = true;
			return bLoaded;
		}
		, setActionTimer: function(val){
			this.actionTimer = val;
		}
		, getActionTimer: function(){
			return this.actionTimer;
		}
		, setMyInfo: function(thisData){
			this.myInfo = thisData;
			this.displayMyInfo();
		}
		, displayMyInfo: function(){
			var $layer = this.$getInfoLayer();
			var thisClass = this;
			
			var genderC = {
				"M": "sex_m"
				, "F": "sex_w"
			}
			
			var myInfo = _gf.getMyInfoData();
			
			$layer.find(">dt:eq(0) img").attr("src", _gf.filePath2Url(myInfo["이미지"])).error(function(){
				$(this).attr("src", _gf.getDefaultProfileImage(myInfo["성별코드"]));
			});
			$layer.find("dd:first p.mem_name a").html(myInfo["닉네임"]);
			$layer.find("dd:first ul.mem_info>li:eq(0)").attr("class", genderC[myInfo["성별코드"]]).html(myInfo["성별"]);
			$layer.find("dd:first ul.mem_info>li:eq(1)").html(myInfo["나이대"]);
			$layer.find("dd:first ul.mem_info>li:eq(2)").html(myInfo["지역명"]);
			$layer.find("dd:first dl.average>dd:eq(0)").html(myInfo["평균타수"]);
			$layer.find("dd:first dl.average>dd:eq(1)").html(myInfo["핸디"]);
			
			$layer.find("p.link img[alt='휴대폰']").hide();
			if(myInfo["모바일앱"] == "Y")$layer.find("p.link img[alt='휴대폰']").show();
			
			$layer.find("p.link img[alt='페이스북']").hide();
			if(myInfo["페이스북ID"] == "Y")$layer.find("p.link img[alt='페이스북']").show();
			
		}
		, loginSpinStart: function(){
			var $loginLayer = this.$getLoginLayer();
			
			$loginLayer.hide();
			if($loginLayer.parent().find("div#tmpSpin").length == 0){
				$loginLayer.parent().prepend("<div id='tmpSpin' style='position:relative; width:225px; height:100px;'></div>");
			}
			$loginLayer.prev("div#tmpSpin").spin().show();
		}
		, loginSpinEnd: function(){
			var $loginLayer = this.$getLoginLayer();
			
			$loginLayer.prev("div#tmpSpin").spin(false).hide();
			$loginLayer.show();
		}
		, getSaveId: function(){
			var $layer = this.$getLayer();
			return $layer.find("input:checkbox").prop("checked");
		}
		, setSaveId: function(){
			var $layer = this.$getLayer();
			var save_id = _util.getCookie("save_id");
			
			if(save_id){
				this.$getInputID().val(save_id);
				this.$getInputID().trigger("blur");
				$layer.find("input:checkbox").prop("checked", true);
			}
		}
	}
	
	
	// footer
	function clsFooter()
	{
		this._HTMLDom = null;
		this.bLoaded = false;
		this._loadpage = _ROOT + "/inc/footer.html";
		this._load();
	}
	
	
	clsFooter.prototype = {
		_load : function(){
			var thisClass = this;
			var $layer = $("footer");
			this._HTMLDom = {
				"$layer": $layer
			}
			
			if($layer.children().length > 0){
				$layer.prepend("<div></div>").children(":first").load(this._loadpage, function(){
					thisClass._init();
				});
			}else{
				$layer.load(this._loadpage, function(){
					thisClass._init();
				});
			}
		}
		, _init: function(){
			this.bLoaded = true;
		}
		, $getLayer: function(){
			return this._HTMLDom["$layer"];
		}
		, isLoaded: function(){
			return this.bLoaded;
		}
	}
	
	// 프로필 레이어
	function clsProfileLayer(direction){
		this._HTMLDom = null;
		this.data = null;
		this.direction = direction;
		this.objPos = null;
		this._loadpage = _ROOT + "/inc/layer.html div.round_box";
		
		this._init();
	}
	
	clsProfileLayer.prototype = {
		_init: function(){
			var thisClass = this;
			this.data = {
				"아이디": null
				, "이미지": null
				, "닉네임": null
				, "성별": null
				, "핸디": null
				, "비거리": null
			}
			
			this.objPos = {
				"left": 0
				, "top": 0
			}
			
			if(!this.direction) this.direction = "right";
			
			$("body").append("<div id='idProfileLayer' style='z-index:100;'></div>").find("#idProfileLayer").hide().load(this._loadpage, function(){
				var $layer = $("#idProfileLayer");
				
				thisClass._HTMLDom = {
					"$layer": $layer
				}
				
				$layer.on("click", "img[alt='쪽지'], img[alt='페이스북']", function(){
					var alt = $(this).attr("alt");
					
					switch(alt){
						case "쪽지":
							_gf.popNote(thisClass.data["아이디"]);
							break;
						case "페이스북":
							$("body").append("<a href='http://www.facebook.com/" + this.data["페이스북ID"] + "' target='_blank' rel='external' />");
							$("a:last").get(0).click();
							$("a:last").remove();
					}
				});
				
				$layer.find("p.img>img").width(50).height(50);
				
				$layer.hover(function(){
					thisClass._HTMLDom["$layer"].show();
				}, function(){
					thisClass._HTMLDom["$layer"].hide();
				});
			});
		}
		, $getLayer: function(){
			return this._HTMLDom["$layer"];
		}
		, show: function($obj){
			var $layer = this._HTMLDom["$layer"];
			var pos = $obj.offset();
			var szClass = "";
			
			$layer.find("div:first").removeClass("arr_r arr_l");
			switch(this.direction){
				case "left":
					szClass = "arr_l";
					break;
				case "right":
					szClass = "arr_r";
					break;
			}
			
			var genderClass = {
				"M": "sex_m"
				, "F": "sex_w"
			}
			
			$layer.find("div:first").addClass(szClass);
			
			if(this.data["이미지"]){
				$layer.find("p.img>img").attr("src", _gf.filePath2Url(this.data["이미지"])).unbind("error").error(function(){
					$(this).attr("src", _gf.getDefaultProfileImage());
				});
			}else{
				$layer.find("p.img>img").attr("src", _gf.getDefaultProfileImage());
			}
			
			
			$layer.find("span.name").html("<em>" + this.data["닉네임"] + "</em>" + _util.nvl(this.data["지역명"])+ " / " + _util.nvl(this.data["나이대"]));
			$layer.find("ul.info_num>li:eq(0)").attr("class", genderClass[this.data["성별코드"]]).html(this.data["성별"]);
			$layer.find("ul.info_num>li:eq(1) span").html(_util.nvl(this.data["핸디"], 0));
			$layer.find("ul.info_num>li:eq(2) span").html(_util.nvl(this.data["평균타수"], 0));
			
			$layer.find("img[alt='페이스북']").hide();
			if(this.data["페이스북ID"] == "Y") $layer.find("img[alt='페이스북']").show();
			
			$layer.find("img[alt='휴대폰']").hide();
			if(this.data["모바일앱"] == "Y") $layer.find("img[alt='휴대폰']").show();
			
			$layer.css({"position": "absolute", "left": (pos.left+this.objPos["left"])+"px", "top": (pos.top+this.objPos["top"])+"px"});
			$layer.show();
		}
		, hide: function(){
			this.$getLayer().hide();
		}
		, setData: function(obj){
			this.data = obj;
		}
		, setDirection: function(val){
			this.direction = val;
		}
		, setLeft: function(val){
			this.objPos["left"] = val;
		}
		, setTop: function(val){
			this.objPos["top"] = val;
		}
		, open: function($obj, thisData, direction, left, top){
			if(direction) this.setDirection(direction);
			if(left == 0 || left) this.setLeft(left);
			if(top == 0 || top) this.setTop(top);
			this.setData(thisData);
			this.show($obj);
		}
	}
		
	function clsMemberLayer(direction){
		this._HTMLDom = null;
		this.data = null;
		this.direction = direction;
		this.objPos = null;

		this._loadpage = _ROOT + "/inc/layer.html div.help_box";
		
		this._init();
	}
	
	clsMemberLayer.prototype = {
		_init: function(){
			var thisClass = this;
			this.data = [
				{
//							"아이디": null
//							, "이미지": null
//							, "닉네임": null
				}
			];
			
			if(!this.direction) this.direction = "right";
			this.objPos = {
				"left": 0
				, "top": 0
			}
			
			$("body").append("<div id='idMemberLayer' style='z-index:100;'></div>").find("#idMemberLayer").hide().load(this._loadpage, function(){
				var $layer = $("#idMemberLayer");
				$layer.find("ul:first>li:first img").width(35).height(35);
				$layer.find("a").remove();
				
				thisClass._HTMLDom = {
					"$layer": $layer
					, "$element": $layer.find("ul:first>li:first").clone(true)
				}
				
				$layer.hover(function(){
					$layer.show();
				}
				, function(){
					$layer.hide();
				});
			});
		}
		, show: function($obj){
			var $layer = this._HTMLDom["$layer"];
			var $element = this._HTMLDom["$element"];
			var pos = $obj.offset();
			var szClass = "";
			var thisClass = this;
			
			switch(this.direction){
				case "left":
					szClass = "arr_l";
					break;
				case "right":
					szClass = "arr_r";
					break;
			}
			$layer.find("div:first").removeClass("layer_w01 layer_w02 arr_l arr_r").addClass(szClass).addClass("layer_w02");
			
			$layer.find("ul:first").empty();
			for(var i=0;i<this.data.length;i++){
				$layer.find("ul:first").append($element.clone(true));
			}
			$layer.find("ul:first>li").each(function(n){
				if(thisClass.data[n]["이미지"]){
					$(this).find("img").attr("src", _gf.filePath2Url(thisClass.data[n]["이미지"])).error(function(){
						$(this).attr("src", _gf.getDefaultProfileImage());
					});
				}else{
					$(this).find("img").attr("src", _gf.getDefaultProfileImage());
				}
				$(this).find("span:first").html(thisClass.data[n]["닉네임"]);
			});
			
			$layer.css({"position": "absolute", "left": (pos.left+this.objPos["left"])+"px", "top": (pos.top+this.objPos["top"])+"px"});
			$layer.show();
		}
		, hide: function(){
			this._HTMLDom["$layer"].hide();
		}
		, setData: function(obj){
			this.data = obj;
		}
		, setDirection: function(val){
			this.direction = val;
		}
		, setLeft: function(val){
			this.objPos["left"] = val;
		}
		, setTop: function(val){
			this.objPos["top"] = val;
		}
		, open: function($obj, thisData, direction, left, top){
			if(direction) this.setDirection(direction);
			if(left == 0 || left) this.setLeft(left);
			if(top == 0 || top) this.setTop(top);
			this.setData(thisData);
			this.show($obj);
		}
	}
	
//	function clsJoinroomLayer(){
//		this._HTMLDom = null;
//		this.data = null;
//		this.objPos = null;
//		this.btn = null;
//
//		this._loadpage = _ROOT + "/inc/layer.html div.help_box";
//		
//		this._init();
//	}
//	
//	clsJoinroomLayer.prototype = {
//		_init: function(){
//			var thisClass = this;
//			this.data = [
//				{
////							"아이디": null
////							, "이미지": null
////							, "닉네임": null
//				}
//			];
//			
//			this.objPos = {
//				"left": 0
//				, "top": 0
//			}
//			
//			$("body").append("<div style='height:15px; width:100px; display:none; z-index:100;' /><div id='idJoinroomLayer' style='z-index:100;'></div>").find("#idJoinroomLayer").hide().load(this._loadpage, function(){
//				thisClass._HTMLDom = {
//					"$layer": $("#idJoinroomLayer")
//					, "$toplayer": $("#idJoinroomLayer").prev("div")
//					, "$element": $("#idJoinroomLayer ul li:first").clone(true)
//				}
//				
//				thisClass._HTMLDom["$layer"].add(thisClass._HTMLDom["$toplayer"]).mouseenter(function(){
//					thisClass.show();
//				}).mouseleave(function(){
//					thisClass.hide();
//				});
//			});
//		}
//		, show: function($obj){
//			var $layer = this._HTMLDom["$layer"];
//			var $toplayer = this._HTMLDom["$toplayer"];
//			
//			if(!$obj){
//				$layer.show();
//				$toplayer.show();
//				return;
//			}
//			
//			
//			var pos = $obj.offset();
//			var thisClass = this;
//			
//			$layer.find("ul").empty();
//			for(var i=0;i<this.data.length;i++){
//				$layer.find("ul").append(this._HTMLDom["$element"].clone(true));
//			}
//			$layer.find("ul li").each(function(n){
//				$(this).find("img:first").attr("src", _gf.filePath2Url(thisClass.data[n]["이미지"])).width(35).height(35);
//				$(this).find("span").html(thisClass.data[n]["닉네임"]);
//			});
//			
//			$layer.css({"position": "absolute", "left": (pos.left+this.objPos["left"])+"px", "top": (pos.top+this.objPos["top"])+"px"});
//			$toplayer.css({"position": "absolute", "left": $layer.css("left"), "top": parseInt($layer.css("top"))-parseInt($toplayer.css("height"))+"px"}).width($layer.width());
//			$layer.find("a:has(img)").hide();
//			if(this.btn) $layer.find("a:has(img[alt='" + this.btn + "'])").show();
//			$layer.show();
//			$toplayer.show();
//		}
//		, hide: function(){
//			this._HTMLDom["$layer"].hide();
//			this._HTMLDom["$toplayer"].hide();
//		}
//		, setData: function(obj){
//			this.data = obj;
//		}
//		, setBtn: function(val){
//			this.btn = val;
//		}
//		, setLeft: function(val){
//			this.objPos["left"] = val;
//		}
//		, setTop: function(val){
//			this.objPos["top"] = val;
//		}
//		, open: function($obj, thisData, btn, left, top){
//			if(btn) this.setBtn(btn);
//			if(left == 0 || left) this.setLeft(left);
//			if(top == 0 || top) this.setTop(top);
//			this.setData(thisData);
//			this.show($obj);
//		}
//	}
	
	
	// 화면 로딩
	function clsModalLoading(){
			this.idName = "idModalLoading";
			this.$text = null;
			
			this._init();
	}
	
	clsModalLoading.prototype = {
		_init: function(){
			//$("body").append("<div id='" + this.idName + "' style='position:relative; text-align:center;'><p style='position:absolute; top:40%; left:50%;'></p></div>");
			$("body").append("<div id='" + this.idName + "' style='display:none; overflow:hidden; width:100px; height:100px;'><div style='position:relative; width:100%; height:100%; left:50%; top:50%'></div><div style='position:relative; width:100%; height:0%'></div></div>");
			
			/*$("#" + this.idName).dialog({
				disabled: true
				, autoOpen: false
				, closeOnEscape: false
				, draggable: false
				, height: 100
				, width: 100
				, modal: true
				, resizable: false
				, create: function (event, ui){
					$(".ui-dialog-titlebar").css("display", "none");
				}
			});*/
		}
		, setText: function(val){
			if(val){
				$("#" + this.idName).find("div:eq(0)").css({
					height: "80%"
					, top: "40%"
				});

				$("#" + this.idName).find("div:eq(1)").height("20%").html(val);
			}else{
				$("#" + this.idName).find("div:eq(0)").css({
					height: "100%"
					, top: "50%"
				});
			}
		}
		, open: function(szText){
			var thisClass = this;
			
			$("#" + this.idName).remove();
			this._init();
			
//			if($("#" + this.idName).length == 0){
//				this._init();
//			}
			
			if(szText === false) this.setText(false);
			else if(szText) this.setText(szText);
				
			if($.blockUI){
				$("#" + this.idName).find("div:first").spin({shadow: true});
				//$("#" + this.idName).dialog("open");
				$.blockUI({
					message: $("#" + this.idName)
					, css: {
						width: "100px"
						, height: "100px"
						, left: "50%"
						, top: "50%"
					}
				});
			}else{
				setTimeout(function(){
					thisClass.open();
				}, 100);
			}
		}
		, close: function(){
			var thisClass = this;
			
			if($.unblockUI){
				$("#" + this.idName).find("div:first").spin(false);
				//$("#" + this.idName).dialog("close");
				$.unblockUI();
			}else{
				setTimeout(function(){
					thisClass.close();
				}, 100);
			}
		}
	}
	
	// 페이징
	function clsPaging($layer, countPerPage, pagePerBlock){
		this._HTMLDom = {
			"$layer": $layer
		}
		
		this.pageData = {
			"현재페이지": null
			, "페이지당수": countPerPage
			, "블럭당페이지": pagePerBlock
			, "전체수": null
		}
		
		this._loadpage = _ROOT + "/inc/layer.html ul.pagenum_area";
		this.bLoaded = null;
		
		this._init();
	}
	
	clsPaging.prototype = {
		_init: function(){
			var thisClass = this;
			var $layer = this._HTMLDom["$layer"];

			$layer.load(this._loadpage, function(){
				thisClass._HTMLDom["$element"] = $layer.find("li:not(.pagen_btn):first").clone(true);
				
				$layer.find("li:not(.pagen_btn)").remove();
				
				thisClass._bind();
				
				thisClass.bLoaded = true;
			});
		}
		, $getLayer: function(){
			return this._HTMLDom["$layer"];
		}
		, getLoaded: function(){
			return this.bLoaded;
		}
		, _bind: function(){
			var $layer = this._HTMLDom["$layer"];
			var thisClass = this;
			
			// 화살표 버튼 클릭시
			$layer.find("li.pagen_btn a").click(function(event){
				event.preventDefault();
				
				var idx = $layer.find("li.pagen_btn a").index($(this));
				var curPage = thisClass.pageData["현재페이지"];
				var totalPage = Math.ceil(thisClass.pageData["전체수"]/thisClass.pageData["페이지당수"]);
				
				if((idx < 2 && curPage == 1) || (idx > 1 && curPage >= totalPage)) return;
				
				switch(idx){
					case 0:
						curPage = 1;
						break;
					case 1:
						curPage --;
						break;
					case 2:
						curPage++;
						break;
					case 3:
						curPage = totalPage;
						break;
				}
				thisClass.setPage(curPage);
				$(thisClass).trigger("evtPageClick");
			});
		}
		, setTotalCount: function(val){
			this.pageData["전체수"] = val;
		}
		, setPage: function(val){
			this.pageData["현재페이지"] = val;
			this.display();
		}
		, getPage: function(val){
			return this.pageData["현재페이지"];
		}
		, getCountPerPage: function(){
			return this.pageData["페이지당수"];
		}
		, getPagePerBlock: function(){
			return this.pageData["블럭당페이지"];
		}
		, getTotalCount: function(){
			return this.pageData["전체수"];
		}
		, display: function(){
			var thisClass = this;
			
			_util.executeThread(function(){
				return thisClass.getLoaded();
			}, function(){
				thisClass.displayImple();
			});
		}
		, displayImple: function(){
			var $layer = this._HTMLDom["$layer"];
			var $element = this._HTMLDom["$element"];
			var startPage = Math.ceil(this.pageData["현재페이지"]/this.pageData["페이지당수"]);
			var endPage = startPage+this.pageData["블럭당페이지"]-1;
			var totalPage = Math.ceil(this.pageData["전체수"]/this.pageData["페이지당수"]);
			var thisClass = this;
			
			if(endPage > totalPage) endPage = totalPage;
			
			$layer.find("li:not(.pagen_btn)").remove();
			
			for(var i=startPage;i<=endPage;i++){
				$layer.find("li.pagen_btn:eq(2)").before($element.clone(true)).prev("li").find("a").html(i);
			}
			
			$layer.find("li:not(.pagen_btn)").removeClass("point").eq(this.pageData["현재페이지"]-1).addClass("point"); // 현재 페이지에 클래스 설정
			// 페이지 버튼 클릭시
			$layer.find("li:not(.pagen_btn) a").click(function(event){
				event.preventDefault();
				
				var curPage = thisClass.pageData["현재페이지"];
				var thisPage = $layer.find("li:not(.pagen_btn) a").index($(this))+1;
				
				if(curPage == thisPage) return;
				
				thisClass.setPage(thisPage);
				
				$(thisClass).trigger("evtPageClick");
			});
		}
	}
	
	// 작은페이징
	function clsTinyPaging($layer, countPerPage){
		this._HTMLDom = {
			"$layer": $layer
		}
		
		this.pageData = {
			"현재페이지": null
			, "페이지당수": countPerPage
			, "전체수": null
		}
		
		this._loadpage = _ROOT + "/inc/layer.html p.paging";
		
		this.bLoaded = null;
		
		this._init();
	}
	
	clsTinyPaging.prototype = {
		_init: function(){
			var thisClass = this;
			var $layer = this._HTMLDom["$layer"];

			$layer.load(this._loadpage, function(){
				thisClass._bind();
				thisClass.bLoaded = true;
			});
		}
		, $getLayer: function(){
			return this._HTMLDom["$layer"];
		}
		, _bind: function(){
			var $layer = this._HTMLDom["$layer"];
			var thisClass = this;
			
			// 화살표 버튼 클릭시
			$layer.find("a").click(function(){
				var idx = $layer.find("a").index($(this));
				var curPage = thisClass.pageData["현재페이지"];
				var totalPage = Math.ceil(thisClass.pageData["전체수"]/thisClass.pageData["페이지당수"]);
				
				if((idx == 0 && curPage == 1) || (idx == 1 && curPage >= totalPage)) return;
				
				switch(idx){
					case 0:
						curPage --;
						break;
					case 1:
						curPage++;
						break;
				}
				thisClass.setPage(curPage);
				$(thisClass).trigger("evtPageClick");
				
				thisClass.bLoaded = true;
			});
		}
		, getLoaded: clsPaging.prototype.getLoaded
		, setTotalCount: clsPaging.prototype.setTotalCount
		, setPage:clsPaging.prototype.setPage
		, getPage:clsPaging.prototype.getPage
		, getCountPerPage: clsPaging.prototype.getCountPerPage
		, getTotalCount: clsPaging.prototype.getTotalCount
		, display: clsPaging.prototype.display
		, displayImple: function(){
			var $layer = this._HTMLDom["$layer"];
			
			var totalPage = Math.ceil(this.pageData["전체수"]/this.pageData["페이지당수"]);
			var thisClass = this;
			
			$layer.find("span").html(this.pageData["현재페이지"]);
			$layer.find("p.paging").contents().filter(function(){
				return (this.nodeType==3 && this.data.trim());
			}).before("/" + totalPage).remove();
		}
	}
	
	
	// 리스트 데이터용 인터페이스
	function clsListData()
	{
		this.listData = null;
	}
	
	clsListData.prototype = {
		setList: function(thisData){
			this.areaCodeList = thisData;
		}
		, isLoaded: function(){
			if(this.listData) return true;
			else return false;
		}
		, getKey: function(n){
			return this.listData[n]["키"]+"";
		}
		, getText: function(n){
			return this.listData[n]["내용"]+"";
		}
		, getKey2Idx: function(key){
			for(var i=0;i<this.listData.length;i++){
				if(this.getKey(i) == key+"") return i;
			}
			
			return -1;
		}
	}
	
	function clsGlobalComm()
	{
		this._init();
	}
	
	clsGlobalComm.prototype = {
		_init: function(){

		}
		// 내정보
		, getMyInfo: function(arg){
			var thisClass = this;
			
			arg["콜백"] = arg["콜백"] || function(){};
			
			//ajax
			var serviceName = "getMyUserInfo";
			document.objGlobal.ajax({
				"sid": "US001"
				, "servicename": serviceName
			}, {
				
			}, function(ret){
				var res = {
					"결과코드": ret["msp"]["contents"]["serviceResult"]
					, "메시지": document.objGlobal.getResultMsg(ret)
					, "결과값": {}
				}
				
				var infoData = {};
				
				var items = ret["msp"]["contents"]["items"];
				if(items){
					var obj = items;

					var genderText = {
						"": ""
						, "M": "남자"
						, "F": "여자"
					}
					
					infoData = {
						"아이디": _util.nvl(obj["userId"])
						, "이메일": _util.nvl(obj["email"])
						, "닉네임": _util.nvl(obj["nickname"])
						, "성별코드": _util.nvl(obj["sex"])
						, "성별": genderText[_util.nvl(obj["sex"])]
						, "나이코드": _util.nvl(obj["age"])
						, "나이대": ""
						, "지역코드": _util.nvl(obj["region"])
						, "지역명": ""
						, "핸디": _util.nvl(obj["handi"], 0)
						, "평균타수": _util.nvl(obj["average"], 0)
						, "이미지": _util.nvl(obj["path"]) + _util.nvl(obj["saveFileName"])
						, "원본파일명": _util.nvl(obj["orgnFileName"])
						, "직업": _util.nvl(obj["job"])
						, "통신사": _util.nvl(obj["telInc"]).trim()
						, "휴대폰": _util.nvl(obj["phonenum"])
						, "정보메일수신여부": _util.nvl(obj["emailreceiveYn"])
						, "이름": _util.nvl(obj["userName"])
						, "조인룸초대수신여부": _util.nvl(obj["invitereceiveYn"])
						, "페이스북ID": _util.nvl(obj["facebookId"])
						, "모바일앱": _util.nvl(obj["mobileAppYn"])
					}
					
					res["결과값"] = infoData;
				}
				
				_util.executeThread(function(){
					return _gf.getAreaCodeData() && _gf.getAgeCodeData();
				}, function(){
					infoData["지역명"] = _util.nvl(_gf.getAreaText(infoData["지역코드"]));
					infoData["나이대"] = _util.nvl(_gf.getAgeText(infoData["나이코드"]));
					
					_gf.setMyInfo(res);
					arg["콜백"].apply(null, [res, infoData, arg]);
				});
			});
		}
		// 회원정보
		, getMemberInfo: function(arg){
			//ajax
			var serviceName = "getUserInfo";
			document.objGlobal.ajax({
				"sid": "US001"
				, "servicename": serviceName
				, "listcount": 1
				, "currpageno": 1
			}, {
				"userId": arg["아이디"]
			}, function(ret){
				var res = {
					"결과코드": ret["msp"]["contents"]["serviceResult"]
					, "메시지": document.objGlobal.getResultMsg(ret)
				}
				
				
				var items = ret["msp"]["contents"]["items"];
				
				var info = {};
				if(items){
					var obj = items;
					
					var objSex = {
						"M": "남성"
						, "F": "여성"
					}
					
					info = {
						"아이디": _util.nvl(obj["userId"])
						, "이메일": _util.nvl(obj["email"])
						, "닉네임": _util.nvl(obj["nickname"])
						, "성별코드": _util.nvl(obj["sex"])
						, "성별": _util.nvl(objSex[obj["sex"]])
						, "나이코드": _util.nvl(obj["age"])
						, "나이대": ""
						, "지역코드": _util.nvl(obj["region"])
						, "지역명": ""
						, "핸디": _util.nvl(obj["handi"], 0)
						, "평균타수": _util.nvl(obj["everage"], 0)
						, "이미지": _util.nvl(obj["path"]) + _util.nvl(obj["saveFileName"])
						, "페이스북ID": _util.nvl(obj["facebookId"])
						, "모바일앱": _util.nvl(obj["mobileAppYn"])
					}
					
					_util.executeThread(function(){
						return _gf.getAreaCodeData() && _gf.getAgeCodeData();
					}, function(){
						info["지역명"] = _util.nvl(_gf.getAreaText(info["지역코드"]));
						info["나이대"] = _util.nvl(_gf.getAgeText(info["나이코드"]));
						
						arg["콜백"].apply(null, [res, info, arg]);
					});
				}
			});
		}
		// 지역정보
		, getAreaList: function(arg){
			var thisClass = this;
			
			arg = arg || {};
			
			//ajax
			var serviceName = "getSelectRegion";
			document.objGlobal.ajax({
				"sid":"JR001",
				"servicename":serviceName,
				"listcount":10,
				"currpageno":1
			}, {
				
			}, function(ret){
				var res = {
					"결과코드": ret["msp"]["contents"]["serviceResult"]
					, "메시지": document.objGlobal.getResultMsg(ret)
				}
				
				var arr = [];
				
				if(res["결과코드"] == "00000"){
					if(!ret["msp"]["contents"]["items"].length){
						ret["msp"]["contents"]["items"] = new Array(ret["msp"]["contents"]["items"]);
					}
				}
				
				for(var i=0;i<ret["msp"]["contents"]["items"].length;i++){
					var obj = ret["msp"]["contents"]["items"][i];
					
					if(obj["value"]){
						arr.push({
							"지역코드": obj["value"]
							, "내용": obj["cname"]
							, "지역명": obj["cname"].substr(0, obj["cname"].indexOf("("))
						});
					}
				}
				
				arg["콜백"].apply(null, [res, arr, arg]);
			}, null, arg["동기화"]);
		}
		// 나이정보
		, getAgeList: function(arg){
			var thisClass = this;
			
			//ajax
			var serviceName = "registFormSelectAge";
			document.objGlobal.ajax({
				"sid":"JR001",
				"servicename":serviceName,
				"listcount":10,
				"currpageno":1
			}, {
				
			}, function(ret){
				var res = {
					"결과코드": ret["msp"]["contents"]["serviceResult"]
					, "메시지": document.objGlobal.getResultMsg(ret)
				}
				
				var arr = [];
				
				if(res["결과코드"] == "00000" && ret["msp"]["contents"]["items"]){
					var items = ret["msp"]["contents"]["items"];
					
					if(!items.length){
						items = new Array(items);
					}
					
					for(var i=0;i<items.length;i++){
						var obj = items[i];
						
						arr.push({
							"나이코드": obj["value"]
							, "내용": obj["cname"]
						});
					}
					
					arg["콜백"].apply(null, [res, arr, arg]);
				}
			}, null, arg["동기화"]);
		}
		// 평균타수
		, getAvgList: function(arg){
			var thisClass = this;
			
			//ajax
			var serviceName = "getSelectAverage";
			document.objGlobal.ajax({
				"sid":"JR001",
				"servicename":serviceName,
				"listcount":10,
				"currpageno":1
			}, {
				
			}, function(ret){
				var res = {
					"결과코드": ret["msp"]["contents"]["serviceResult"]
					, "메시지": document.objGlobal.getResultMsg(ret)
				}
				
				var arr = [];
				
				if(res["결과코드"] == "00000" && ret["msp"]["contents"]["items"]){
					var items = ret["msp"]["contents"]["items"];
					
					if(!items.length){
						items = new Array(items);
					}
					
					for(var i=0;i<items.length;i++){
						var obj = items[i];
						
						arr.push({
							"평균타수코드": obj["value"]
							, "내용": obj["cname"]
						});
					}
					
					arg["콜백"].apply(null, [res, arr, arg]);
				}
			}, null, arg["동기화"]);
		}
		// 알림
		, getAlimList: function(arg){
			var thisClass = this;
			
			arg = arg || {};
			arg["콜백"] = arg["콜백"] || function(){};
			
			//ajax
			var serviceName = "getNotificationList";
			var options = {
				"notificationType": arg["알림구분코드"]
				, "period": arg["조회기간"]
				, "topFlag": arg["상단알림여부"]
				, "serviceGrp": arg["서비스구분코드"]
			}
			_gf.ajax({
				"sid": "NC001"
				, "servicename": serviceName
				, "listcount": 100000
				, "currpageno": 1
			}, options, function(ret){
				var res = {
					"결과코드": ret["msp"]["contents"]["serviceResult"]
					, "메시지": _gf.getResultMsg(ret)
					, "알림구분코드": arg["알림구분코드"]
					, "결과값": []
				}
				
				var items = ret["msp"]["contents"]["items"];
				if(items){
					if(!items.length) items = new Array(items);
					
					for(var i=0;i<items.length;i++){
						var obj = items[i];
						var d1 = _util.nvl(obj["regDate"])+"";
						var d2 = _util.nvl(obj["modDate"])+"";
						var t1 = _util.nvl(obj["regTime"])+"";
						var t2 = _util.nvl(obj["modTime"])+"";
						
						res["결과값"].push({
							"알림코드": _util.nvl(obj["notificationSeq"])
							, "대상아이디": _util.nvl(obj["targetUserId"])
							, "링크":  _util.nvl(obj["targetUrl"])
							, "경과시간":  _util.nvl(obj["timelag"])
							, "템플릿코드": _util.nvl(obj["templateId"])
							, "인자값들": _util.nvl(obj["param"])
							, "등록정보": {
								 "아이디": _util.nvl(obj["regId"])
								 , "일자": d1.substrEx(0, 4) + "." + d1.substrEx(4, 2) + "." + d1.substrEx(6, 2)
								 , "시간": t1.substrEx(0, 2) + ":" + t1.substrEx(2, 2)
							}
							, "수정정보": {
								"아이디": _util.nvl(obj["modId"])
								, "일자": d2.substrEx(0, 4) + "." + d2.substrEx(4, 2) + "." + d2.substrEx(6, 2)
								, "시간": t2.substrEx(0, 2) + ":" + t2.substrEx(2, 2)
							}
							, "상단여부": _util.nvl(obj["notificationType"])
							, "알림구분": _util.nvl(obj["serviceGrp"])
							, "읽음여부": _util.nvl(obj["readYn"])
							, "내용": _util.nvl(obj["contents"])
							, "프로필": []
							, "아이디": []
						});
					}
				}
				
				arg["콜백"].apply(null, [res]);
			});
		}
	}
	
	function clsCommonComm()
	{
		// 부킹알람
		this.bookingAlarmList = null;
		// 친구알람
		this.friendAlarmList = null;
		// 로그인
		this.loginData = null;
		this.loginRequest = null;
		// 알람
		this.alarmList = null;
	}
	
	clsCommonComm.prototype = {
		// 부킹알람
		getBookingAlarmList: function(key){
			var thisClass = this;
			
			//ajax
			setTimeout(function(){
				thisClass.bookingAlarmList = [
					{
						"종류": "부킹예약"
						, "아이디": null // 조인룸초대, 조인룸참여
						, "닉네임": null // 조인룸초대, 조인룸참여
						, "키": "001"
						, "메시지": "2012.02.12 예정인 부킹을 예약하였습니다."
					}
					, {
						"종류": "조인룸초대"
						, "아이디": "sky72" // 조인룸초대, 조인룸참여
						, "닉네임": "골프알바" // 조인룸초대, 조인룸참여
						, "키": "001"
						, "메시지": "골프알바 님의 조인룸 초대"
					}
					, {
						"종류": "조인룸참여"
						, "아이디": "sky72" // 조인룸초대, 조인룸참여
						, "닉네임": "바보퉁이" // 조인룸초대, 조인룸참여
						, "키": "001"
						, "메시지": "바보퉁이 님이 회원님의 조인룸에 참여하였습니다."
					}
					, {
						"종류": "예정조인룸참여"
						, "아이디": "sky72" // 조인룸초대, 조인룸참여
						, "닉네임": "쿠하카" // 조인룸초대, 조인룸참여
						, "키": "001"
						, "메시지": "쿠하카 님이 2012.02.12 예정인  조인룸에 참여하였습니다."
					}
				];
				document.objCommonControl.finishBookingAlarmList();
			}, 500);
		}
		, getBookingAlarmData: function(){
			return this.bookingAlarmList;
		}
		// 친구알람
		, getFriendAlarmList: function(key){
			var thisClass = this;
			
			//ajax
			setTimeout(function(){
				thisClass.friendAlarmList = [
					{
						"종류": "친구요청" // 친구요청
						, "아이디": "sky72" // 친구요청
						, "닉네임": "바보퉁이1" // 친구요청
						, "이미지": "../images/board/default_35_35.gif"
						, "메시지": "바보퉁이1 님의 친구요청"
					}
					, {
						"종류": "친구요청" // 친구요청
						, "아이디": "sky73" // 친구요청
						, "닉네임": "바보퉁이2" // 친구요청
						, "이미지": "../images/board/default_35_35.gif"
						, "메시지": "바보퉁이2 님의 친구요청"
					}
					, {
						"종류": "친구요청" // 친구요청
						, "아이디": "sky74" // 친구요청
						, "닉네임": "바보퉁이3" // 친구요청
						, "이미지": "../images/board/default_35_35.gif"
						, "메시지": "바보퉁이3 님의 친구요청"
					}
				];
				
				document.objCommonControl.finishFriendAlarmList();
			}, 500);
		}
		, getFriendAlarmData: function(){
			return this.friendAlarmList;
		}
		// 로그인
		, setLoginRequest: function(key, val){
			if(!this.loginRequest) this.loginRequest = {};
			
			if(typeof key == "object") this.loginRequest = key;
			else this.loginRequest[key] = val;
		}
		, getLoginInfo: function(){
			var thisClass = this;
			
			this.loginData = {};
			
			//ajax
			var serviceName = "login";
			document.objGlobal.ajax({
				"sid":"US001",
				"servicename":serviceName,
				"listcount":10,
				"currpageno":1
			}, {
				"userId":  thisClass.loginRequest["아이디"]
				, "pw": thisClass.loginRequest["비밀번호"]
			}, function(ret){
				thisClass.loginData = {
					"결과코드": ret["msp"]["contents"]["serviceResult"]
					, "아이디": null
					, "메시지": document.objGlobal.getResultMsg(ret)
				}
				
				if( ret["msp"]["contents"]["serviceResult"] == "00000"){
					thisClass.loginData["아이디"] = ret["msp"]["contents"]["items"][0]["userNo"];
				}
				
				document.objCommonControl.finishLoginInfo();
			});
		}
		, getLoginData: function(){
			return this.loginData;
		}
		// 알람
		, getAlarmList: function(key){
			var thisClass = this;
			
			//ajax
			setTimeout(function(){
				thisClass.alarmList = [
					{
						"종류": "나의동호회게시글" // 나의동호회게시글, 나의글나이스샷, 나의동호회가입, 나의글댓글
						, "키": "001"
						, "메시지": "바보퉁이 님이 대학생 골프연합회의 필드에 게시글을 남겼습니다."
						, "아이디": "sky72"
						, "닉네임": "바보퉁이"
						
					}
					, {
						"종류": "나의글나이스샷" // 나의동호회게시글, 나의글나이스샷, 나의동호회가입, 나의글댓글
						, "키": "001"
						, "메시지": "쿠하카 님이 회원님의 글에 나이스샷을 외쳤습니다."
						, "아이디": "sky73"
						, "닉네임": "쿠하카"
						
					}
					, {
						"종류": "나의동호회가입" // 나의동호회게시글, 나의글나이스샷, 나의동호회가입, 나의글댓글
						, "키": "001"
						, "메시지": "바보퉁이 님이 우리동네 골프클럽 동호회에 가입하였습니다."
						, "아이디": "sky72"
						, "닉네임": "바보퉁이"
						
					}
					, {
						"종류": "나의글댓글" // 나의동호회게시글, 나의글나이스샷, 나의동호회가입, 나의글댓글
						, "키": "001"
						, "메시지": "쿠하카 님이 회원님의 글에 댓글을 남겼습니다."
						, "아이디": "sky73"
						, "닉네임": "쿠하카"
						
					}
				];
				
				$(thisClass).trigger("evtFinishAlarmList");
				document.objCommonControl.finishAlarmList();
			}, 500);
		}
		, getAlarmData: function(){
			return this.alarmList;
		}
		// 알림 펼침
		, openAlimSubmit: function(arg){
			var thisClass = this;
			
			arg = arg || {}
			arg["콜백"] = arg["콜백"] || function(){}
			
			//ajax
			var serviceName = "clickTopNotification";
			var options = {
				"notificationType": arg["종류코드"]
			}
			_gf.ajax({
				"sid": "NC001"
				, "servicename": serviceName
			}, options, function(ret){
				var res = {
					"결과코드": ret["msp"]["contents"]["serviceResult"]
					, "메시지": _gf.getResultMsg(ret)
				}
				
				arg["콜백"].apply(null, [res]);
			});
		}
	}
	
	// 화면 구성 프레임
	function clsCommonControl()
	{
		this.objComm = null;
		this.objTopMenu = null;
		this.objLeftMenu = null;
		this.objFooter = null;
	}
	
	clsCommonControl.prototype = {
		init: function(){
			var thisClass = this;
			
			this.objComm = new clsCommonComm();
			
			// top메뉴 객체 생성
			if($("body header").is("header")) this.objTopMenu = new clsTopMenu();
			
			// 왼쪽 메뉴가 없는 페이지는 left메뉴 객체 생성하지 않음.
			if($("div.#container:first").children().is("#left_area")) this.objLeftMenu = new clsLeftMenu();
			
			// footer 객체 생성
			this.objFooter = new clsFooter();
			
			this._bind();
			
			if(this.objLeftMenu) this._leftMenuBind();
			if(this.objTopMenu) this._topMenuBind();
			
			_util.executeThread(function(){
				return thisClass.objFooter.isLoaded();
			}, function(){
				thisClass._footerBind();
			});
			
			// 로그인시
			if(_util.getCookie("member_id")){
				// 나의 정보 받아오기
				_gf.getMyInfo({
					"콜백": function(ret, infoData, args){
						if(thisClass.objLeftMenu) thisClass.objLeftMenu.setMyInfo(infoData);
					}
				});
			
				// 부킹알람
				_gf.getAlimList({
					"알림구분코드": "B"
					, "조회기간": ""
					, "상단알림여부": "Y"
					, "서비스구분코드": ""
					, "콜백": function(ret){
						thisClass.finishBookingAlimList(ret);
					}
				});
				//this.objComm.getBookingAlarmList(document.objUtil.getCookie("member_id"));
				// 알림
				_gf.getAlimList({
					"알림구분코드": "N"
					, "조회기간": ""
					, "상단알림여부": "Y"
					, "서비스구분코드": ""
					, "콜백": function(ret){
						thisClass.finishAlimList(ret);
					}
				});
				//this.objComm.getFriendAlarmList(document.objUtil.getCookie("member_id"));
				// 쪽지
				_gf.getAlimList({
					"알림구분코드": "M"
					, "조회기간": ""
					, "상단알림여부": "Y"
					, "서비스구분코드": ""
					, "콜백": function(ret){
						thisClass.finishNoteAlimList(ret);
					}
				});
				//this.objComm.getAlarmList(document.objUtil.getCookie("member_id"));
			}
		}
		, _bind: function(){
			var thisClass = this;
			
			$(document).on("click", "map[name='home']", function(){
				var e = arguments[0] || event;
				e.preventDefault();
				
				document.location.href = _ROOT + "/index";
			});
		}
		, _leftMenuBind: function(){
			var thisClass = this;
			
			// 비밀번호 엔터시 로그인
			this.objLeftMenu.$getLayer().on("keydown", "input:password", function(){
				if(event.keyCode == 13) thisClass.login();
			});

			// 대메뉴 마우스오버
			this.objLeftMenu.$getsMenuStep1().on("mouseenter", null, function(){
				var actionTimer = thisClass.objLeftMenu.getActionTimer();
				if(actionTimer) thisClass.objLeftMenu.setActionTimer(clearTimeout(actionTimer));
				
				// 대메뉴 전체 볼드 off
				(thisClass.objLeftMenu.$getsMenuStep1()).find("img").each(function(){
					var s = $(this).attr("src");
					$(this).attr("src", s.replace("_on", ""));
				})
				
				// 선택대메뉴 볼드 on
				var s = $(this).find("img").attr("src");
				$(this).find("img").attr("src", s.replace(".gif", "_on.gif"));
				
				
				var $layer = $(this).next();
				
				// 전체 하위메뉴 숨김
				thisClass.objLeftMenu.$getsMenuStep2().not($layer).stop().hide("fast");
				
				// 현재 하위메뉴 보임
				$layer.show("slow");
			}).on("mouseleave", null, function(){
				var iTimer = setTimeout(function(){
					thisClass.objLeftMenu.setDefault();
				}, 500);
				
				thisClass.objLeftMenu.setActionTimer(iTimer);
			});
			
			// 하위메뉴 마우스오버
			this.objLeftMenu.$getsMenuStep2().on("mouseenter", "li", function(){
				var actionTimer = thisClass.objLeftMenu.getActionTimer();
				if(actionTimer) thisClass.objLeftMenu.setActionTimer(clearTimeout(actionTimer));
				
				// 전체 하위메뉴 이미지 off
				thisClass.objLeftMenu.$getsMenuStep2().find("img").each(function(){
					var s = $(this).attr("src");
					$(this).attr("src", s.replace("_on", ""));
				});
				
				// 현재 하위메뉴 이미지 on
				var s = $(this).find("img").attr("src");
				$(this).find("img").attr("src", s.replace(".gif", "_on.gif"));
			}).on("mouseleave", "li", function(){
				var iTimer = setTimeout(function(){
					thisClass.objLeftMenu.setDefault();
				}, 500);
				
				thisClass.objLeftMenu.setActionTimer(iTimer);
			});
			
			
			// 로그아웃
			this.objLeftMenu.$getLayer().on("click", "img[alt='로그아웃'], img[alt='쪽지'], p.btn_log", function(){
				var tName = this.tagName.toUpperCase();
				
				switch(tName){
					case "IMG":
						var bName = $(this).attr("alt");
						switch(bName){
							case "로그아웃":
								_gf.logout();
								break;
							case "쪽지":
								document.location.href = _ROOT + "/mypage/my_note.html";
								break;
						}
						break;
					case "P":
						if($(this).hasClass("btn_log")){
							thisClass.login();
						}
						break;
				}
			});
			
			
			// 디폴트 메뉴 설정
			this.objLeftMenu.setActionTimer(setTimeout(function(){
				thisClass.objLeftMenu.setDefault();
			}, 1));
			
			// 마이골프인
			this.objLeftMenu.$getLayer().find("a").has("img[alt='마이골프인']").attr({
				"id": "idPermissionLink"
				, "href": _ROOT + "/mypage/my_home.html"
			});
			
			// 회원가입
			this.objLeftMenu.$getLayer().find("a").filter(function(){
				return $(this).text() == "회원가입";
			}).attr("id", "idPermissionLink");
			
			// 아이디 비밀번호 찾기
			this.objLeftMenu.$getLayer().find("dl.left_member a:eq(1)").attr({
				"id": "idPermissionLink"
			});
		}
		, _topMenuBind: function(){
			var thisClass = this;
			
			// 로그아웃
			this.objTopMenu.$getLayer().on("click", "a", function(){
				var tx = $(this).text();
				
				switch(tx){
					case "로그인":
						_gf.goLogin();
						break;
					case "로그아웃": 
						_gf.logout();
						break;
				}
			});
			
			this.objTopMenu.$getLayer().on("click", "a", function(){
				var e = e || event;
				
				e.cancelBubble = true;
				
				var alt = $(this).text();
				var t;
				
				switch(alt){
					case "부킹":
						t = "B";
					
						thisClass.objTopMenu.$getLayer().find("ul:first>li:eq(0) div.top_booking").toggle("fast");
						thisClass.objTopMenu.$getLayer().find("ul:first>li:eq(1) div.top_friend").hide("fast");
						thisClass.objTopMenu.$getLayer().find("ul:first>li:eq(2) div.top_info").hide("fast");
						break;
					case "알림":
						t = "N";
						
						thisClass.objTopMenu.$getLayer().find("ul:first>li:eq(0) div.top_booking").hide("fast");
						thisClass.objTopMenu.$getLayer().find("ul:first>li:eq(1) div.top_friend").toggle("fast");
						thisClass.objTopMenu.$getLayer().find("ul:first>li:eq(2) div.top_info").hide("fast");
						break;
					case "쪽지":
						t = "M";
						
						thisClass.objTopMenu.$getLayer().find("ul:first>li:eq(0) div.top_booking").hide("fast");
						thisClass.objTopMenu.$getLayer().find("ul:first>li:eq(1) div.top_friend").hide("fast");
						thisClass.objTopMenu.$getLayer().find("ul:first>li:eq(2) div.top_info").toggle("fast");
						break;
					case "골프인 로고":
						document.location.href = _ROOT + "/index";
						break;
				}
				
				if(t){
					thisClass.objComm.openAlimSubmit({
						"종류코드": t
						, "콜백": function(ret){
							switch(t){
								case "B":
									thisClass.objTopMenu.$getLayer().find("div.top_booking").prev().html(0).hide();
									break;
								case "N":
									thisClass.objTopMenu.$getLayer().find("div.top_friend").prev().html(0).hide();
									break;
								case "M":
									thisClass.objTopMenu.$getLayer().find("div.top_info").prev().html(0).hide();
									break;
							}
						}
					})
				}
			});
			
			this.objTopMenu.$getLayer().on("click", "div.top_booking, div.top_friend, div.top_info", function(){
				var e = e || event;
				
				e.cancelBubble = true;
			});
			
			
			
			this.objTopMenu.$getLayer().on("click", "a", function(){
				if($(this).is(":contains('부킹정보 전체보기')")){
					document.location.href = _ROOT + "/mypage/my_booking.html";
				}else if($(this).is(":contains('알림내역 전체보기')")){
					document.location.href = _ROOT + "/mypage/my_alim.html";
				}else if($(this).is(":contains('쪽지내역 전체보기')")){
					document.location.href = _ROOT + "/mypage/my_note.html";
				}
			});
			
			this.objTopMenu.$getLayer().on("click", "p.top_sub_logo a", function(){
				document.location.href = _ROOT + "/index";
			});
			
			$(document).on("click", null, function(){
				thisClass.objTopMenu.$getLayer().find("ul:first>li:eq(0) div.top_booking").hide("fast");
				thisClass.objTopMenu.$getLayer().find("ul:first>li:eq(1) div.top_friend").hide("fast");
				thisClass.objTopMenu.$getLayer().find("ul:first>li:eq(2) div.top_info").hide("fast");
			});
		}
		, _footerBind: function(){
			this.objFooter.$getLayer().find("a").has(":not(img[alt='이메일 무단수집거부'])").attr("id", "idPermissionLink");
			
			this.objFooter.$getLayer().on("click", "img[alt='이메일 무단수집거부']", function(){
				var winEmail = window.open(_ROOT + "/popup/pop_email_reject.html", "winEmail", "width=600, height=300");
				if(winEmail) winEmail.focus();
			});
		}
		// 부킹알람 완료
		, finishBookingAlarmList: function(){
			var thisData = this.objComm.getBookingAlarmData();
				
			if(this.objTopMenu) this.objTopMenu.setBookingAlarmList(thisData);
		}
		// 친구알람 완료
		, finishFriendAlarmList: function(){
			var thisData = this.objComm.getFriendAlarmData();
				
			if(this.objTopMenu) this.objTopMenu.setFriendAlarmList(thisData);
		}
		// 로그인
		, login: function(){
			var id = (this.objLeftMenu.$getInputID()).val();
			var passwd = (this.objLeftMenu.$getInputPasswd()).val();
			
			if(id == ""){
				alert("아이디를 입력해 주십시요.");
				(this.objLeftMenu.$getInputID()).trigger("focus");
				return;
			}else if(passwd == ""){
				alert("비밀번호를 입력해 주십시요.");
				(this.objLeftMenu.$getInputPasswd()).trigger("focus");
				return;
			}
			
			this.objComm.setLoginRequest("아이디", id);
			this.objComm.setLoginRequest("비밀번호", passwd);
			this.objLeftMenu.loginSpinStart();
			this.objComm.getLoginInfo();
		}
		// 로그인완료
		, finishLoginInfo: function(){
			var thisData = this.objComm.getLoginData();
				
			_gf.spinEnd();
			
			var saveid;
			if(this.objLeftMenu){
				this.objLeftMenu.loginSpinEnd();
				saveid = this.objLeftMenu.getSaveId();
			}
			
			if(thisData["메시지"]) alert(thisData["메시지"]);
			if(thisData["결과코드"] != "00000") return;
			
			_gf.loginProc({
				"아이디": thisData["아이디"]
				, "아이디저장": saveid
			});
			document.location.reload();
		}
		// 알람완료
		, finishAlarmList: function(){
			var thisData = this.objComm.getAlarmData();
				
			if(this.objTopMenu) this.objTopMenu.setAlarmList(thisData);
		}
		// 부킹알림 완료
		, finishBookingAlimList: function(ret){
			if(this.objTopMenu) this.objTopMenu.setBookingAlimList(ret["결과값"]);
		}
		// 알림 완료
		, finishAlimList: function(ret){
			if(this.objTopMenu) this.objTopMenu.setAlimList(ret["결과값"]);
		}
		// 쪽지 알림 완료
		, finishNoteAlimList: function(ret){
			if(this.objTopMenu) this.objTopMenu.setNoteAlimList(ret["결과값"]);
		}
	}
	
	
	
	// 전역 클래스
	function clsGlobal(){
		this.objComm = null;
		this.objProfileLayer = null;
		this.objMemberLayer = null;
		//this.objJoinroomLayer = null;
		this.objModalLoading = null;
		this.clsPaging = null;
		this.clsTinyPaging = null;
		
		this.loginAuthList = null;
		
		this.resultMsg = null;
		this._finishPreload = null;
		
		this.shortUrl = null;
		
		this.myInfo = null;
		this.areaCodeList = null;
		this.ageCodeList = null;
	}
	
	clsGlobal.prototype = {
		init: function(){
			this.objComm = new clsGlobalComm();
			this.objProfileLayer = new clsProfileLayer();
			this.objMemberLayer = new clsMemberLayer();
			//this.objJoinroomLayer = new clsJoinroomLayer();
			this.objModalLoading = new clsModalLoading();
			this.clsPaging = clsPaging;
			this.clsTinyPaging = clsTinyPaging;
			
			// 페이지에 사용될 정보를 비동기식으로 로드
			this._preload();
			
			this._bind();
		}
		, _preload: function(){
			var thisClass = this;
			
			// 로그인 정책
			$.ajax({
				url: _ROOT + "/inc/auth.policy"
				, type: "get"
				, dataType: "json"
				, async: false
				, success: function(ret, sta){
					thisClass.loginAuthList = ret;
					
					thisClass.authCheck(null, true, function(){
						history.back();
					});
				}
				, error:function(e){
					alert("error");
				}
			});
			
			// 서버 메시지맵
			$.ajax({
				url: _ROOT + "/inc/result.message"
				, type: "get"
				, dataType: "json"
				, async: false
				, success: function(ret, sta){
					thisClass.resultMsg = ret;
				}
			});
			
			// 지역코드
			this.getAreaCodeList({
				"콜백": function(r, l){
					thisClass.areaCodeList = l;
				}
			});
			
			// 나이대 코드
			this.getAgeCodeList({
				"콜백": function(r, l){
					thisClass.ageCodeList = l;
				}
			});
			
			_util.executeThread(function(){
				return gapi;
			}, function(){
				_util.executeThread(function(){
					return gapi.client;
				}, function(){
					gapi.client.load('urlshortener', 'v1', function(){
						var request = gapi.client.urlshortener.url.insert({
							'resource': {
								'longUrl': document.location.href
							}
						});
						
						request.execute(function(r) {
							thisClass.shortUrl = r["id"];
						});
					});
				});
			});
		}
		, _bind: function(){
			var thisClass = this;
			
			
		}
		// 로그아웃
		, logout: function(){
			var thisClass = this;
			
			this.ajax({
				"sid":"US001",
				"servicename":"logout",
				"listcount":10,
				"currpageno":1
			}, {
				
			}, function(ret){
				_util.delCookie("member_id", "/");
				
				var sf = _util.getSelfFileName();
				
				if(sf[sf.length-2] == "my_privacy"){
					document.location.href = _ROOT + "/index";
				}else{
					document.location.reload();
				}
			});
		}
		// 일반 에디터 메뉴 옵션
		, getCKOption: function(){
			var ret = {
				toolbar: [
					{ name: 'document', items : [ 'Source' ] },
					{ name: 'clipboard', items : [ 'Paste','PasteText','-','Undo','Redo' ] },
					{ name: 'colors', items : [ 'TextColor','BGColor' ] },
					{ name: 'insert', items : [ 'Smiley','SpecialChar' ] },
					{ name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] },
					{ name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl' ] },
					{ name: 'links', items : [ 'Link','Unlink' ] },
					{ name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] },
					{ name: 'my', items : [ 'uploadfile' ]	}
				]
				, contentsCss: _ROOT + '/css/common.css'
			};
			
			//if($.browser.msie) ret["toolbar"].splice(-1, 1);
			
			return ret;
		}
		// 동호회 에디터 메뉴 옵션
		, getCKClubOption: function(){
			var ret = {
				toolbar: [
					{ name: 'document', items : [ 'Source' ] },
					{ name: 'clipboard', items : [ 'Paste','PasteText','-','Undo','Redo' ] },
					{ name: 'colors', items : [ 'TextColor','BGColor' ] },
					{ name: 'insert', items : [ 'Smiley','SpecialChar' ] },
					{ name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl' ] },
					{ name: 'links', items : [ 'Link','Unlink' ] },
					"/",
					{ name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] },
					{ name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] },
					{ name: 'my', items : [ 'uploadfile' ]	}
				]
				, contentsCss: _ROOT + '/css/common.css'
			};
			
			//if(!$.browser.msie) ret["toolbar"].splice(-2, 1);
			
			return ret;
		}
		// DCD 결과와 메시지 매핑
		, getResultMsg: function(result, aVar){
			var sid = result["msp"]["params"]["pub"]["sid"];
			var serviceName = result["msp"]["params"]["pub"]["servicename"];
			var resultCode = result["msp"]["contents"]["serviceResult"];
			
			//alert(sid + '-' + serviceName + '-' + resultCode);
			
			if(!this.resultMsg) return null;
			if(!this.resultMsg[sid]) return null;
			if(!this.resultMsg[sid][serviceName]) return null;
			if(!this.resultMsg[sid][serviceName][resultCode]) return null;
			
			var szRet = this.resultMsg[sid][serviceName][resultCode];
			
			if(aVar){
				for(var i=0;i<aVar.length;i++){
					while(szRet.indexOf("{" + i + "}") != -1){
						szRet = szRet.replace("{" + i + "}", aVar[i]);
					}
				}
			}
			return szRet;
		}
		// DCD요청 req생성
		, getRequestString: function(objPub, objParameter){
			var szPub = "";
			var szParameter = "";
			var szRet = '{"msp":{"header":{"client":"","device":{"model":"UNIT-1","firmware":"ios292sd","ip":"192.168.0.1"}},';
			
			szRet += '"params":{"pub":{';
			
			if(typeof objPub == "string"){
				szPub = objPub;
			}else{
				for(var key in objPub){
					if(szPub) szPub += ",";
					szPub += '"' + key + '":"' + objPub[key] + '"';
				}
			}
			
			szRet += szPub + "},";
			szRet += '"parameter":[';
			
			if(typeof objParameter == "string"){
				szParameter += objParameter;
			}else{
				for(var key in objParameter){
					if(objParameter[key] != null){
						if(szParameter) szParameter += ",";
						szParameter += '{"@name":"' + key + '","$":"' + objParameter[key] + '"}';
					}
				}
			}
			
			szRet += szParameter + "]}}}";
			
			return szRet;
		}
		// DCD요청
		, ajax: function(objPub, objParameter, callback, bDebug, sync){
			var thisClass = this;
			
			if(bDebug){
				this.objModalLoading.close();
				
				if($("textarea#idDebug").length == 0){
					$("body").prepend("<textarea id='idDebug' />");
				}
				$("textarea#idDebug").val(this.getRequestString(objPub, objParameter));
			}
			
			var url = {
				"192.168.0.82": "http://192.168.0.81:8080/dcd/request.do"
				, "www.golfinsns.com": "http://110.45.186.84:8080/dcd/request.do"
			}
			
			$.ajax({
				url: url[document.domain]
				//url: "/request.do"
				, type: "GET"
				, data: {
					"userid": _util.nvl(_util.getCookie("member_id"))
					, "method": "json"
					, "req": this.getRequestString(objPub, objParameter)
				}
				, dataType: "jsonp"
				, jsonp: "msp300"
				, timeout: 10000
				, success: function(ret, sta){
					if(ret["msp"]["result"]["code"] != "00000"){
						_gf.spinEnd();
						alert("시스템 오류입니다. 관리자에게 문의 바랍니다.\n오류코드 " + objPub["servicename"] + "_" + ret["msp"]["result"]["code"]);
						return;
					}else if(ret["msp"]["contents"]["serviceResult"] != "00000"){
						if(_util.getCookie("member_id") == "khs01"){
							_gf.spinEnd();
							alert("디버거 모드 가동중: " + objPub["servicename"] + " - " + ret["msp"]["contents"]["serviceResult"]);
							$("body").append("<textarea />").find("textarea:last").val(thisClass.getRequestString(objPub, objParameter));
						}
					}
					callback(ret);
				}
				, error: function(xhr, sta, err){
					if(!$.browser.msie && _util.getCookie("member_id") == "khs01"){
						_gf.spinEnd();
						alert("시스템 오류입니다. 관리자에게 문의 바랍니다.\n오류코드  " + objPub["servicename"] + "_E454900");
						$("body").append("<textarea />").find("textarea:last").val(thisClass.getRequestString(objPub, objParameter));
					}
					return;
				}
				, complete: function(xhr, sta){

				}	
				, beforeSend: function(){
					
				}
			});
		}
		//  파일업로드
		, uploadFile: function(thumbSize, callback){
			var thisClass = this;
			
			var opt = {
				url:_ROOT + '/UploadFile'
				, secureuri:false
				, fileElementId: "khs_uploadfile"
				, dataType: 'json'
				, beforeSend:function(){
					//$("#loading").show();
				}
				, complete:function(){
					thisClass.spinEnd();
				}
				, success: function (data, status){
					callback(data);
					
//					data = {
//						"결과코드": "00000"
//						, "파일리스트": [
//							{
//								"파일명": null
//								, "원본파일명": null
//								, "파일크기": null
//								, "섬네일": null
//							}
//						]
//					}
				}
				, error: function (data, status, e){
					alert("파일 업로드 에러");
				}
			}
			
			if(thumbSize) opt["data"] = {"thumbSize": thumbSize};
			
			if($("input:file#" + opt["fileElementId"]).length == 0){
				$("body").prepend("<input type='file' name='" + opt["fileElementId"]+ "' id='" + opt["fileElementId"] + "' style='position:absolute; opacity:0;filter:alpha(opacity=0); border:none; background:none;' onFocus='this.blur();'>");
			}
			
			$(document).on("change", "input:file#" + opt["fileElementId"], function(){
				document.objGlobal.spinStart("uploading...");
				$.ajaxFileUpload(opt)
			});
			
			if(!$.browser.msie){
				$("input:file#" + opt["fileElementId"]).trigger("click");
			}
		}
		// 이미지를 업로드용 버튼으로 변환
		, setUploadFileImage: function($img, thumbSize, callback, forcePos){
			var fileElementId = "khs_uploadfile";
			var thisClass = this;
			
			if($.browser.msie){
				if(!$img.width()){
					_util.executeThread(function(){
						return $img.width();
					}, function(){
						thisClass.setUploadFileImage($img, thumbSize, callback);
					});
					
					return;
				}
				
				$insObj = $img;
				if($img.parent("a").length > 0){
					$insObj = $img.parent("a");
				}
				
				forcePos = forcePos || $insObj.position();
				
				$img.css("visibility", "hidden");
				
				$insObj.after('<label for="' + fileElementId + '" style="position:absolute; z-index:10; left:' + forcePos["left"] + 'px; top:' + forcePos["top"] + 'px; background:url(' + $img.attr("src") + ') no-repeat; width:' + $img.width() + 'px; height:' + $img.height() + 'px; text-indent:-9999px; cursor:pointer;">파일첨부</label>');
				//var $label = $insObj.next("label");
				
				
			}
			
			if($.browser.msie){
				thisClass.uploadFile(thumbSize, callback);
			}else{
				$img.unbind("click").click(function(){
					thisClass.uploadFile(thumbSize, callback);
				});
			}
		}
		// 이미지가 아닌 DOM을 파일업로드 버튼으로 변환
		, setUploadFileButton: function($target, imgSrc, w, h, thumbSize, callback){
			var fileElementId = "khs_uploadfile";
			var thisClass = this;
			
			if($.browser.msie){
				var p = $target.position();
				
				if(!p["left"]){
					_util.executeThread(function(){
						var p = $target.position();
						
						return p["left"];
					}, function(){
						thisClass.setUploadFileButton($target, imgSrc, w, h, thumbSize, callback);
					});
					
					return;
				}
				
				$insObj = $target;
				
				if($insObj.prev("label").length > 0) return;
				
				$insObj.before('<label for="' + fileElementId + '" style="position:absolute; left:0; top:0; background:url(' + imgSrc + ') no-repeat; width:' + w + 'px; height:' + h + 'px; text-indent:-9999px; cursor:pointer;">파일첨부</label>');
				var $label = $insObj.prev("label");
				
				var targetPos = $insObj.position();
				
				$label.css({
					left: targetPos["left"]
					, top: targetPos["top"]
				});
				
				$target.css("visibility", "hidden");
			}
			
			if($.browser.msie){
				thisClass.uploadFile(thumbSize, callback);
			}else{
				$target.unbind("click").click(function(){
					thisClass.uploadFile(thumbSize, callback);
				});
			}
		}
		// HTML편집기 내 이미지 업로드 버튼 구현
		, setCKEditorUploadFileButton: function(editor, callback){
			if($.browser.msie){
				var $target = $("a.cke_button_uploadfile");
				
				this.setUploadFileButton($target, _ROOT + "/inc/ckeditor_3.6.3/plugins/uploadfile/uploadfile.png", 100, 17, null, callback); 
			}else{
				$(editor).bind("uploadFile", function(){
					_gf.uploadFile(null, callback);
				});
			}
		}
		// 로그인 페이지 이동
		, goLogin: function(q_url, params){
			if(q_url){
				var thisPage =  encodeURIComponent(q_url);
			}else{
				var thisPage = encodeURIComponent(document.location.href);
			}
			
			document.location.href = _ROOT + "/member/login.html?q_url=" + thisPage + (params ? "&"+params:"");
		}
		, filePath2Url: function(uri){
			if(!uri) return "";
			
			if(uri.indexOf("/tmp/") == -1){
				var szPath = _UPLOADPATH;
				var szUrl = _UPLOADURL;
			}else{
				var szPath = _UPLOADPATH_TMP;
				var szUrl = _UPLOADURL_TMP;
			}
			
			return uri.replace(szPath, szUrl);
			
			//return uri.replace("/data/msp300/dl/files/free/", _ROOT + "/__img/");
		}
		, fileUrl2Path: function(url){
			if(url.indexOf("/tmp/") == -1){
				var szPath = _UPLOADPATH;
				var szUrl = _UPLOADURL;
			}else{
				var szPath = _UPLOADPATH_TMP;
				var szUrl = _UPLOADURL_TMP;
			}
			
			return url.replace(szUrl, szPath);
			
			//return url.replace( _ROOT + "/__img/", "/data/msp300/dl/files/free/");
		}
		, filePath2UrlSC: function(url){
			return url.replace("/data/msp300/dl/files/free/admin/notice/", _ROOT + "/_course_super_img/");
		}
		, filePath2UrlA: function(url){
			return url.replace("/data/msp300/dl/files/free/asp/editinfo/course/", _ROOT + "/_course_img/");
		}
		// 나의정보 요청
		, getMyInfo: function(arg){
			this.objComm.getMyInfo(arg);
		}
		// 나의 정보 요청 완료
		, setMyInfo: function(res){
			if(res["결과코드"] != "00000") res["결과값"] = res["결과코드"];
			
			this.myInfo = res["결과값"];
		}
		// 회원정보 요청
		, getMemberInfo: function(arg){
			this.objComm.getMemberInfo(arg);
		}
		// 로그인 처리
		, loginProc: function(arg){
			document.objUtil.setCookie("member_id", arg["아이디"], null, "/");
			
			if(arg["아이디저장"]){
				_util.setCookie("save_id", arg["아이디"], null, "/");
			}else{
				_util.delCookie("save_id", "/");
			}
		}
		// 전체로딩
		, spinStart: function(st){
			this.objModalLoading.open(st);
		}
		// 전체로딩 종료
		, spinEnd: function(){
			this.objModalLoading.close();
		}
		// 프로파일 레이어
		, showProfileLayer: function($obj, thisData, direction, left, top){
			this.objProfileLayer.open($obj, thisData, direction, left, top);
		}
		, closeProfileLayer: function(){
			this.objProfileLayer.hide();
		}
		// 회원 레이어
		, showMemberLayer: function($obj, thisData, direction, left, top){
			this.objMemberLayer.open($obj, thisData, direction, left, top);
		}
		, closeMemberLayer: function(){
			this.objMemberLayer.hide();
		}
		// 지역정보 요청
		, getAreaCodeList: function(arg){
			this.objComm.getAreaList(arg);
		}
		// 나이정보 요청
		, getAgeCodeList: function(arg){
			this.objComm.getAgeList(arg);
		}
		// 평균타수 정보 요청
		, getAvgCodeList: function(arg){
			this.objComm.getAvgList(arg);
		}
		// 나의 정보
		, getMyInfoData: function(){
			return this.myInfo;
		}
		// 기본 프로파일 이미지
		, getDefaultProfileImage: function(gender){
			var img = _ROOT + "/images/board/default_100_120.gif";
			
			switch(gender){
				case "M":
					img = _ROOT + "/images/board/default_100_120.gif";
					break;
				case "F":
					img = _ROOT + "/images/board/default_100_120.gif";
					break;
			}
			
			return img;
		}
		// 페이징 생성
		, makePaging: function($obj, countPerPage, pagePerBlock){
			var np = new clsPaging($obj, countPerPage, pagePerBlock);
			return np;
		}
		, makeTinyPaging: function($obj, countPerPage, pagePerBlock){
			var np = new clsTinyPaging($obj, countPerPage, pagePerBlock);
			return np;
		}
		// 로그인 정책 실행
		// 결과:
		//	true: 로그인중
		//	false: 비로그인중
		// 결과코드 :
		// 	0: 로그인 중
		//	1: 비로그인 && 로그인 정책 중 확인 매핑
		//	2: 비로그인 && 로그인 정책 중 미확인 매핑
		, authCheck: function(url, bAction, cancelCallback){
			
			url = url || document.location.href;
			cancelCallback = cancelCallback || function(){};
			bAction = Boolean(bAction);
			
			var aFileName = _util.getSelfFileName(url);
			var l = aFileName.length-1;
			
			
			var szFileName = aFileName[l-2] + "/" + aFileName[l-1];
			var objRet = {
				"결과": true
				, "결과코드": 0
			}
			if(!_util.getCookie("member_id")){
				objRet["결과"] = false;
				
				if($.inArray(szFileName, this.loginAuthList["확인"]) > -1){
					objRet["결과코드"] = 1;
				}else if($.inArray(szFileName, this.loginAuthList["미확인"]) > -1){
					objRet["결과코드"] = 2;
				}
			}
			
			
			if(bAction && !objRet["결과"]){
				switch(objRet["결과코드"]){
					case 1:
						if(confirm(_LOGIN_TEXT)){
							this.goLogin();
						}else{
							cancelCallback();
						}
						break;
					case 2:
						this.goLogin();
						break;
				}
			}
			
			return objRet;
		}
		// 지역코드값
		, getAreaText: function(key, bFullText){
			if(!this.areaCodeList) return null;
			
			var szCol = "지역명";
			if(bFullText) szCol = "내용";
			
			for(var i=0;i<this.areaCodeList.length;i++){
				if(this.areaCodeList[i]["지역코드"]+"" == key+"") break;
			}
			
			if(i<this.areaCodeList.length){
				return this.areaCodeList[i][szCol];
			}
			
			return null;
		}
		, getAreaCodeData: function(){
			return this.areaCodeList;
		}
		// 나이대 코드값
		, getAgeText: function(key){
			if(!this.ageCodeList) return null;
			
			for(var i=0;i<this.ageCodeList.length;i++){
				if(this.ageCodeList[i]["나이코드"]+"" == key+"") break;
			}
			
			if(i<this.ageCodeList.length){
				return this.ageCodeList[i]["내용"];
			}
			
			return null;
		}
		, getAgeCodeData: function(){
			return this.ageCodeList;
		}
		// 쪽지팝업
		, popNote: function(q_id){
			var szLink = _ROOT + "/popup/pop_note_send.html?q_id=" + q_id;
			var winNote = window.open(szLink, "winNote", "width=400, height=400, scrollbars=0");
			if(winNote) winNote.focus();
		}
		// 댓글 체크
		, validComment: function(val){
			if(!val){
				alert("등록할 댓글을 입력해 주십시요.");
				return false;
			}else if(_util.getByteLen(val) > 200){
				alert("댓글은 한글 100자 이내로 입력하여 주세요.");
				return false;
			}
			
			return true;
		}
		// 이메일 리스트
		, getEmailList: function(){
			var arr = [
				{
					"이메일": "naver.com"
					, "텍스트": "네이버"
				}
				, {
					"이메일": "daum.net"
					, "텍스트": "다음"
				}
				, {
					"이메일": "nate.com"
					, "텍스트": "네이트"
				}
				, {
					"이메일": "yahoo.co.kr"
					, "텍스트": "야후"
				}
				, {
					"이메일": "gmail.com"
					, "텍스트": "지메일"
				}
				, {
					"이메일": "hotmail.com"
					, "텍스트": "핫메일"
				}
				, {
					"이메일": "chol.com"
					, "텍스트": "천리안"
				}
				, {
					"이메일": "dreamwiz.com"
					, "텍스트": "드림위즈"
				}
				, {
					"이메일": "lycos.co.kr"
					, "텍스트": "라이코스"
				}
				, {
					"이메일": "korea.com"
					, "텍스트": "코리아닷컴 "
				}
				, {
					"이메일": "hanmir.com"
					, "텍스트": "한미르"
				}
				, {
					"이메일": "paran.com"
					, "텍스트": "파란"
				}
				, {
					"이메일": "freechal.com"
					, "텍스트": "프리첼"
				}
				, {
					"이메일": "hanafos.com"
					, "텍스트": "하나포스"
				}
			];
			
			return arr;
		}
		// 알림 요청
		, getAlimList: function(arg){
			this.objComm.getAlimList(arg);
		}
		, $getAlim: function(arg){
			arg = arg || {};
			arg["콜백"] = arg["콜백"] || function(){}
			
			var tmp = document.createElement("DIV");
			$(tmp).load(_ROOT + "/inc/alim.html li#" + arg["템플릿코드"], function(rt, ts){
				var op = {};
				var ar = arg["d"]["인자값들"].split("$#@!");
				for(var i=0;i<ar.length;i++){
					var ar1 = ar[i].split("!@#$");
					op[ar1[0]] = ar1[1];
				}
				
				if(op["게시판종류"]){
					switch(op["게시판종류"]){
						case "D":
							op["게시판종류주소"] = "club_view.html";
							break;
						case "P": 
							op["게시판종류주소"] = "club_picture_view.html";
							break;
					}
				}
				
				arg["인자"] = op;
				
				var params = _util.nvl($(tmp).children().attr("data-param"));
				var ar2 = params.split(",");
				
				
				
				for(var i=0;i<ar2.length;i++){
					$(tmp).children().find("[data-param='" + ar2[i].trim() + "']").html(op[ar2[i].trim()]);
				}
				
				var l = _util.nvl($(tmp).children().attr("data-link"));
				var lp = _util.nvl($(tmp).children().attr("data-linkparam"));
				
				if(l){
					var alp = lp.split(",");
					
					for(var i=0;i<alp.length;i++){
						l = l.replace("{" + i + "}", op[alp[i].trim()]);
					}
					
					$(tmp).children().css("cursor", "pointer").attr("data-link", l).click(function(){
						document.location.href = $(this).attr("data-link");
					});
				}
				
//				$(tmp).children().addClass("top_hover");
				
				$(tmp).children().hover(function(){
					$(this).addClass("top_hover");
				}, function(){
					$(this).removeClass("top_hover");
				});
				
				
				arg["콜백"].apply(null, [$(tmp).children(), arg]);
			});
		}
		, getShortUrl: function(){
			return this.shortUrl;
		}
	}
	
	
	function clsUtil()
	{
		
	}
	
	clsUtil.prototype = {
		// 페이지 전달 인자 파싱
		getParam: function(key){
			var ret = (this.getObjParam())[key];
			if(!ret) ret = "";
			
			return ret;
		}
		, getObjParam: function(){
			var _parammap = {};
		    document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function () {
		        function decode(s) {
		            return decodeURIComponent(s.split("+").join(" "));
		        }
		
		        _parammap[decode(arguments[1])] = decode(arguments[2]);
		    });
		    
		    return _parammap;
		}
		// ie용 placeholder 구현
		, setPlaceHolder: function($obj){
			var i = document.createElement("INPUT");
			
			if (!("placeholder" in i)) {
				var pos = $obj.offset();
				
				$obj.after("<label>" + $obj.attr("placeholder") + "</label>");
				$obj.next("label").css({"position":"absolute", "color":"#999", "display":"none", "cursor":"text", "left":10, "margin-top":4, "width":$obj.width()});
				
				$obj.on("focus", null, function(){
					$(this).next("label").hide();
				}).on("blur", null, function(){
					if(!$.trim($(this).val())) $(this).next("label").show();
					else $(this).next("label").hide();
				}).trigger("blur");
				
				$obj.next("label").on("click", null, function(){
					$obj.trigger("focus");
				});
			}
			
			$(i).remove();
		}
		// 쿠키
		, getCookie: function(name){
			var cname = name + "=";
			var dc = document.cookie;
			if (dc.length > 0) {
				begin = dc.indexOf(cname);
				if (begin != -1) {
					begin += cname.length;
					end = dc.indexOf(";", begin);
					if (end == -1) end = dc.length;
					return unescape(dc.substring(begin, end));
				}
			}
			return null;
		}
		, setCookie: function(name, value, expiredays, path, domain, secure){
			var toDate = new Date();
			toDate.setHours(23);
			toDate.setMinutes(59);
			toDate.setSeconds(59);
			toDate.setDate(toDate.getDate() + expiredays);
			document.cookie = name + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + toDate.toGMTString()) + ((path == null) ? "" : "; path=" + path) + ((domain == null) ? "" : "; domain=" + domain) + ((secure == null) ? "" : "; secure");
		}
		, delCookie: function(name, path, domain){
			if (this.getCookie(name)) {
				document.cookie = name + "=" + ((path == null) ? "" : "; path=" + path) + ((domain == null) ? "" : "; domain=" + domain) + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
			}
		}
		// 바이트 길이
		, getByteLen: function(str){
			var ibyte = 0;

		    for (var i = 0; i < str.length; i++) {
		        var tmp = escape(str.charAt(i));
		        if (tmp.length == 1) ibyte++;
		        else if (tmp.indexOf("%u") != -1) ibyte += 2;
		        else if (tmp.indexOf("%") != -1) ibyte += tmp.length/3;
		    }
		
		    return ibyte;
		}
		// 팝업 크기 자동 조절
		, setWindowSize: function(){
			setTimeout(function(){
				_util.executeThread(function(){
					return _window_loaded;
				}, function(){
					var wrapWidth = $(window).width();
					var wrapHeight = $("body").height();
					
					window.resizeBy(0, $("body").height()-$(window).height()+10);
					
					_util.executeThread(function(){
						return wrapHeight != $("body").height();
					}, function(){
						window.resizeBy(0, $("body").height()-wrapHeight+10);
					});
					
				});
			}, 500);
		}
		// 랜덤생성
		, random: function(iMin, iMax){
			return Math.round(Math.random() * (iMax - iMin)) + iMin;
		}
		// 콤마형 숫자
		, number_format: function(val){
			val += "";
			var Re = /[^0-9]/g;
			var ReN = /(-?[0-9]+)([0-9]{3})/;
			val = val.replace(Re,'');              
			while (ReN.test(val)) { 
				val = val.replace(ReN, "$1,$2"); 
			}
			return val;
		}
		// 오브젝트 복사
		, objectCopy: function(src){
			var constructor = null;
			var dst = null;
			
			if(src.constructor){
				var match = src.constructor.toString().match(/function ([^\(]*)/);
			
				constructor = (match && match[1]) || null;
			}
			
			if(typeof src == "object" && constructor){
				dst = eval("new " + constructor + "()");
				if(src.prototype){
					for(var key in src.prototype){
						dst.prototype[key] = this.objectCopy(src.prototype[key]);
					}
				}
				
				for(var key in src){
					dst[key] = this.objectCopy(src[key]);
				}
				
				return dst;
			}
			
			dst = src;
			
			return dst;
		}
		// 조건실행 쓰레드
		, executeThread: function(bFunction, callback, arg){
			var tf = arguments.callee;
			
			if(!arg) arg = {};
			if(!arg["cnt"]) arg["cnt"] = 0;
			if(!arg["timeout"]) arg["timeout"] = 5000;
			
			arg["cnt"]++;
			
			if(bFunction()){
				callback(arg);
				return;
			}else{
				if(arg["cnt"]*100 > arg["timeout"]){
					if(!arg["onTimeout"]) arg["onTimeout"] = function(){};
					
					arg["onTimeout"](arg);
					return;
				}
				
				setTimeout(function(){
					tf(bFunction, callback, arg);
				}, 100);
			}
		}
		// ajax 전송용 문자열 변환
		, ajaxTrans: function(val){
			return (val+"").ajaxTrans();
		}
		, ajaxEncode: function(val){
			return encodeURIComponent(val);
		}
		, enter2br: function(val){
			return (val+"").enter2br();
		}
		, createListData: function(){
			return new clsListData();
		}
		, nvl: function(val, def){
			if(def !== 0 && !def) def = "";
			
			if(val === 0 || val) return val;
			else return def;
		}
		// 바이트 단위 문자열 자름
		, leftB: function(val, lenB){
			val = val+"";
			
			var szRet = "";
			var iByte = 0;
			for(var i=0;i<val.length;i++){
				var ch = escape(val.charAt(i));
				szRet += val.charAt(i);
				
				if(ch.length == 1){
					iByte++;
				}else if(ch.indexOf("%u") != -1){
					iByte+=2;
				}else if(ch.indexOf("%") != -1){
					iByte+= ch.length/3;
				}
				
				if(iByte >= lenB) break;
			}
			
			if(i < val.length) szRet += "...";
			
			return szRet;
		}
		// 오브젝트를 파라메터 문자열로 반환
		, object2paramString: function(obj){
			var szRet = "";
			for(var key in obj){
				if(szRet) szRet += "&";
				szRet += key + "=" + obj[key];
			}
			
			if(szRet) szRet = "?" + szRet;
			
			return szRet;
		}
		// 파라메터 문자열 필터링
		, paramStringFilter: function(aRemove){
			var params = this.getObjParam();
			
			if(!aRemove) aRemove = [];
			
			var szRet = "";
			for(var key in params){
				if($.inArray(key, aRemove) == -1){
					if(szRet) szRet += "&";
					szRet += key + "=" + params[key];
				}
			}
			
			if(szRet) szRet = "?" + szRet;
			return szRet;
		}
		// 파일경로 및 파일명
		, getSelfFileName: function(href){
			href = href || document.location.href;
			var m = href.match(/(?:.+)\/(.+)\/(.+)\.(html|htm)/);
			
			if(!m) m = href.match(/\/(.+)\/(.+)\.(html|htm)/);
			
			if(!m){
				href += "index.html";
				m = href.match(/(?:.+)\/(.+)\/(.+)\.(html|htm)/);
			}
			
			return m;
		}
		// 반올림
		, roundEx: function(val, p){
			p = p || 0;

			if(p >= 0){
				var n = Math.pow(10, p);
				return Math.round(val/n)*n;
				//return parseInt(n*val+0.5)/n;
			}else{
				var m = Math.pow(10, Math.abs(p));
				return Math.round(val*m)/m;
				//return parseInt((val + m/2)/m)*m;
			}
//			val += "";
//			var arr = val.split(".");
//			if(!arr[1]){
//				arr[1] = "";
//				for(var i=0;i<n;i++){
//					arr[1] += "0";
//				}
//			}
//			
//			if(arr[1].length < n){
//				var nn = n-arr[1].length;
//				
//				for(var i=0;i<nn;i++){
//					arr[1] += "0";
//				}
//			}
//			
//			arr[1] = arr[1].substrEx(0, n);
//			
//			return arr[0] + "." + arr[1];
		}
		, getShortUrl: function(q_url, ret){
			gapi.client.load('urlshortener', 'v1', function(){
				var request = gapi.client.urlshortener.url.insert({
					'resource': {
						'longUrl': q_url
					}
				});
				
				request.execute(function(r) {
					ret["결과값"] = r["id"];
				});
			});
		}
		, facebook_sharer: function(t, d, b, r){
			d = d || "";
			d = this.leftB(d, 80);
			
			t = encodeURIComponent(t);
			d = encodeURIComponent(d);
			b = encodeURIComponent(b);
			r = encodeURIComponent(r);
			
			var szLink = "http://www.golfinsns.com/facebook_sharer?t=" + t + "&d=" + d + "&b=" + b + "&r=" + r
			
			var ret = {};
			this.getShortUrl(szLink, ret);
			
			this.executeThread(function(){
				return ret["결과값"];
			}, function(){
				window.open("http://www.facebook.com/sharer.php?u=" + ret["결과값"]);
			});
		}
	}
	
	document.objUtil = new clsUtil();
	_util = document.objUtil;

	document.objGlobal = new clsGlobal();
	_gf = document.objGlobal;
	_gf.init();
	document.objCommonControl = new clsCommonControl();
	
	document.objCommonControl.init();
	
	//$("body").show();
	$("body").css("visibility", "visible");
	
	_util.executeThread(function(){
		return document.objControl;
	}, function(){
		setTimeout(function(){
			$("body").css("visibility", "visible");
		}, 500);
	}, {
		"onTimeout": function(){
			$("body").css("visibility", "visible");
		}
	});
	
	if($.datepicker){
		// 달력 default 설정
		$.datepicker.setDefaults({
			monthNamesShort: ['1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월']
			, monthNames: ['1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월']
			, dayNamesMin: ['일','월','화','수','목','금','토']
			//, appendText: "yyyy-mm-dd"
			, constrainInput: true
			, weekHeader: "Wk"
			, dateFormat: "yy-mm-dd"
			, autoSize: true
			, changeMonth: true
			, changeYear: true
			, showMonthAfterYear: true
			, showButtonPanel: true
			, closeText: "닫기"
			, showOtherMonths: true
			, selectOtherMonths: true
		});
	}
	
	// 타이틀 설정
	$(document).attr("title", "::: 골프인 :::");
});